ENDIF.
ENDLOOP.
NEW-LINE.
ULINE (54).
ENDIF.
IF p_mrp2 = 'X'.
PERFORM
display_header_mrp.
FORMAT COLOR
2.
LOOP AT
itab_mrp.
WRITE
:/2 itab_mrp-matnr,'|',
23 itab_mrp-werks,
33 '|',
37 itab_mrp-zzgpind,
49 '|',
52 itab_mrp-ZZDATE,
65 '|'.
ENDLOOP.
NEW-LINE.
ULINE (65).
FORMAT COLOR
OFF.
SKIP 4.
WRITE :/
'Records with Errors will not be Included in Session' .
PERFORM
display_header_mrp.
FORMAT COLOR
2.
LOOP AT
ertab_mrp.
IF
NOT ertab_mrp IS INITIAL OR NOT ertab_mrp-matnr IS INITIAL.
WRITE :/2 ertab_mrp-matnr ,'|',
23 ertab_mrp-werks,
33 '|',
37 ertab_mrp-zzgpind,
49 '|' ,
52 ertab_mrp-zzdate,
65 '|'.
ENDIF.
ENDLOOP.
NEW-LINE.
ULINE (65).
ENDIF.
FORMAT COLOR OFF.
ENDFORM.
" display_data
*&---------------------------------------------------------------------*
*&
Form BDC_UPLOAD_basic
*&---------------------------------------------------------------------*
*
text
*------------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------------------------*
FORM bdc_upload_basic.
*CLEAR itab_basic. REFRESH itab_basic.
CLEAR : v_ctr , v_no_lines .
IF NOT itab_basic[] IS INITIAL .
v_group_ctr = '1' .
CONCATENATE 'BASIC_'
v_group_ctr INTO v_group .
PERFORM open_group USING v_group .
LOOP AT itab_basic .
IF v_ctr GE p_max .
PERFORM call_bdc_close_group .
v_group_ctr = v_group_ctr + 1 .
CLEAR
v_group .
CONCATENATE 'BASIC_' v_group_ctr INTO v_group .
PERFORM open_group USING v_group
.
v_ctr = 0 .
ENDIF.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM
bdc_field USING 'RMMG1-MATNR'
itab_basic-matnr.
* 'DEEPAKTESTMAT'.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM
bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'MARA-ZZMATNR'.
PERFORM
bdc_field USING 'MARA-ZZMATNR'
itab_basic-zzmatnr.
*
'ADV#AM29F010-70JI'.
PERFORM
call_bdc_insert USING 'MM02'.
CLEAR
bdcdata . REFRESH bdcdata .
v_no_lines = v_no_lines + 1 .
v_ctr
= v_ctr + 1.
ENDLOOP.
PERFORM
call_bdc_close_group.
SKIP 10.
WRITE :/10
'Session by name BASIC* created' .
WRITE :/10
'Total No of records uploaded - ' , v_no_lines .
ENDIF.
ENDFORM.
" BDC_UPLOAD
*&---------------------------------------------------------------------*
*&
Form display_header
*&---------------------------------------------------------------------*
*
text
*-----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------------------*
FORM display_header.
NEW-LINE.
* set left scroll-boundary column 48.
FORMAT COLOR 1 INTENSIFIED
ON.
ULINE (54).
WRITE :/' Avnet Material',
21'|' ,
23 'Green Product '
, 54 '|'.
NEW-LINE.
ULINE (54).
FORMAT COLOR OFF INTENSIFIED
OFF.
ENDFORM.
*&---------------------------------------------------------------------*
*&
Form bdc_upload_mrp
*&---------------------------------------------------------------------*
*
text
*------------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------------------------*
FORM bdc_upload_mrp.
* PERFORM call_bdc_open_group2.
CLEAR : v_ctr , v_no_lines
.
IF NOT itab_mrp[] IS
INITIAL .
v_group_ctr
= '1' .
CONCATENATE
'MRP_' v_group_ctr INTO v_group
.
PERFORM
open_group USING v_group .
LOOP AT
itab_mrp .
IF
v_ctr GE p_max .
PERFORM call_bdc_close_group .
v_group_ctr = v_group_ctr + 1 .
CLEAR v_group .
CONCATENATE 'MRP2_' v_group_ctr
INTO v_group .
PERFORM open_group USING v_group .
v_ctr = 0 .
ENDIF.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM
bdc_field USING 'RMMG1-MATNR'
itab_mrp-matnr.
*
'DEEPAKTESTMAT'.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(13)'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM
bdc_field USING 'MSICHTAUSW-KZSEL(13)'
'X'.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '0080'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'RMMG1-WERKS'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM
bdc_field USING 'RMMG1-WERKS'
itab_mrp-werks.
* 'sg11'.
PERFORM
bdc_dynpro USING 'SAPLMGMM' '4000'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'MARC-ZZGPIND'.
PERFORM
bdc_field USING 'MARC-ZZGPIND'
itab_mrp-zzgpind.
* 'G'.
PERFORM
bdc_field USING 'BDC_CURSOR'
'MARC-ZZDATE'.
PERFORM
bdc_field USING 'MARC-ZZDATE'
itab_mrp-zzdate.
* 'G'.
PERFORM
bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM
bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM
call_bdc_insert USING 'MM02'.
CLEAR
bdcdata . REFRESH bdcdata .
v_no_lines = v_no_lines + 1 .
v_ctr
= v_ctr + 1.
ENDLOOP.
PERFORM
call_bdc_close_group.
SKIP 10.
WRITE :/10
'Session by name MRP2* created' .
WRITE :/10
'Total No of records uploaded - ' , v_no_lines .
ENDIF.
ENDFORM.
" bdc_upload_mrp
*&---------------------------------------------------------------------*
*&
Form display_header_mrp
*&---------------------------------------------------------------------*
*
text
*-----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------------------*
FORM display_header_mrp.
NEW-LINE.
* set left scroll-boundary column 48.
FORMAT COLOR 1 INTENSIFIED
ON.
ULINE (65).
WRITE :/' Avnet Material',
21'|' ,
23 'Plant ' ,
33 '|',
35 'Indicator',
49 '|',
52 'Date',
65 '|' .
NEW-LINE.
ULINE (65).
FORMAT COLOR OFF INTENSIFIED
OFF.
ENDFORM.
" display_header_mrp
*&---------------------------------------------------------------------*
*&
Form valid_plant_check
*&---------------------------------------------------------------------*
*
text
*-----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*-----------------------------------------------------------------------*
FORM valid_plant_check.
LOOP AT itab_mrp.
IF itab_mrp-matnr
IS INITIAL OR itab_mrp-werks IS INITIAL OR
itab_mrp-zzgpind IS INITIAL.
MOVE-CORRESPONDING
itab_mrp TO ertab_mrp .
APPEND
ertab_mrp . CLEAR ertab_mrp .
DELETE
itab_mrp.
CLEAR
itab_mrp.
CONTINUE.
ENDIF.
SELECT SINGLE * INTO tab_marc FROM marc WHERE matnr = tab_marc-matnr
AND
werks = itab_mrp-werks . .
IF sy-subrc
= 0.
MOVE-CORRESPONDING
itab_mrp TO ertab_mrp .
APPEND
ertab_mrp . CLEAR ertab_mrp .
DELETE
itab_mrp.
CLEAR
itab_mrp.
CONTINUE.
ENDIF.
ENDLOOP.
ENDFORM.
" valid_plant_check
*---------------------------------------------------------------------*
*
FORM open_group
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
FORM open_group USING p_grp .
* open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_grp
user = sy-uname
keep = 'X'.
ENDFORM.
*--------------- This ends the BDC program-- -----------------------------------------*
*Web Site http://sap.niraj.tripod.com ---------------------------------------
*
*SAP Forum http://sapniraj.freeforumsite.com------------------------------------ *