hi ,
i am doing bdc for t-code WG21.
i write code for it. but after processing it . there is no effect in material group also code not giving any errors for this.
below is my code please see and help me.
report Z_GROUPBDCINSERT
no standard page heading line-size 255.
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
* error session opened (' ' or 'X')
w_msg1(51).
DATA: E_GROUP_OPENED.
* message texts
TABLES: T100.
TYPES: BEGIN OF ty_record,
MATKL type MATKL,
wgbez type wgbez,
end of ty_record.
DATA: lt_mat type TABLE OF TY_RECORD,
wa_mat type TY_RECORD.
PARAMETERS p_name type IBIPPARMS-PATH OBLIGATORY.
at SELECTION-SCREEN ON VALUE-REQUEST FOR p_name.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
field_name = ' '
IMPORTING
FILE_NAME = p_name.
TYPES:
ty_record1(4096) TYPE c OCCURS 0 .
DATA:w_struct TYPE TY_RECORD1.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = W_STRUCT
I_FILENAME = p_name
TABLES
I_TAB_CONVERTED_DATA = LT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
start-of-selection.
loop at LT_MAT into WA_MAT.
perform bdc_dynpro using 'SAPMWWG2' '1000'.
perform bdc_field using 'BDC_CURSOR'
'T023D-MATKL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023D-MATKL'
WA_MAT-matkl.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'T023TD-WGBEZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023TD-WGBEZ'
WA_MAT-wgbez.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'T023TD-WGBEZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023TD-WGBEZ'
WA_MAT-wgbez.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'T023TD-WGBEZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'T023TD-WGBEZ'
WA_MAT-wgbez.
perform bdc_dynpro using 'SAPMWWG2' '1100'.
perform bdc_field using 'BDC_CURSOR'
'WWGD-CLASS1'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'T023TD-WGBEZ'
WA_MAT-wgbez.
perform bdc_transaction using 'WG21'.
ENDLOOP.
* WRITE:/ 'success record:-' ,'|', cnt.
* WRITE:/ 'unsuccess record:-' , '|',cnt1.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE 'N'
UPDATE 's'
MESSAGES INTO MESSTAB.
if sy-subrc = 0.
* cnt = cnt + 1.
* else.
* cnt1 = cnt1 + 1.
write 'data insert'.
ENDIF.
LOOP AT MESSTAB into W_MSG1 WHERE MSGTYP eq 'I'.
MESSAGE ID MESSTAB-MSGID
TYPE MESSTAB-MSGTYP
NUMBER MESSTAB-MSGNR
INTO L_MSTRING
WITH MESSTAB-MSGV1
MESSTAB-MSGV2
MESSTAB-MSGV3
MESSTAB-MSGV4.
WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
ENDLOOP.
REFRESH BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> space.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.