hi ,
i having problem when i trying to upload excel file data to sap .
it execute correct but not go inside loop .
i dont understand where is the actual problem.
if any understand tell me below is my code.
report ZSD_XD02_ALL
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')
DATA: E_GROUP_OPENED.
* message texts
TABLES: T100.
DATA: cnt TYPE i VALUE 0,
cnt1 type i VALUE 0.
types: begin of ty_rec,
kunnr type KUNNR,
name1 type NAME1,
abtnr type ABTNR,
name2 type NAME1,
sortl type SORTL,
spras type SPRAS,
stras type STRAS,
ORT01 type ORT01,
ORT02 type ORT02,
pstlz type PSTLZ,
land1 type LAND1,
regio type REGIO,
tzone type TZONE,
telf1 type TELF1,
telfx type TELFX,
name3 type NAME1,
abtnr1 type ABTNR,
name4 type NAME1,
sortl1 type SORTL,
spras1 type SPRAS,
stras1 type STRAS,
ORT011 type ORT01,
ORT021 type ORT02,
pstlz1 type PSTLZ,
land11 type LAND1,
regio1 type REGIO,
tzone1 type TZONE,
telf11 type TELF1,
telfx1 type TELFX,
name5 type NAME1,
PAFKT type PAFKT,
gbdat type GBDAT,
name6 type NAME1,
* sortl2 type SORTL,
spras2 type SPRAS,
stras2 type STRAS,
ORT012 type ORT01,
ORT022 type ORT02,
pstlz2 type PSTLZ,
land12 type LAND1,
regio2 type REGIO,
tzone2 type TZONE,
telf12 type TELF1,
telfx2 type TELFX,
END OF ty_rec.
PARAMETERS p_FILE TYPE IBIPPARMS-PATH OBLIGATORY.
DATA: lt_mat type TABLE OF TY_REC,
wa_mat type TY_REC.
at SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = P_FILE
.
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_file
TABLES
I_TAB_CONVERTED_DATA = LT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
* break hasmukh.
start-of-selection.
*BREAK hasmukh.
loop at lt_mat into wa_mat.
write:/ wa_mat-kunnr.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-D0360'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
wa_mat-kunnr.
perform bdc_field using 'RF02D-D0360'
'X'.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAME1(01)'.
perform bdc_field using 'BDC_OKCODE'
'=LSDP'.
perform bdc_field using 'KNVK-NAME1(01)'
wa_mat-name1.
perform bdc_field using 'KNVK-ABTNR(01)'
wa_mat-abtnr.
perform bdc_dynpro using 'SAPMF02D' '1360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'=ADRP'.
*perform bdc_field using 'KNVK-NAME1'
* 'Work Address'.
*perform bdc_field using 'KNVK-ABTNR'
* 'Z001'.
perform bdc_dynpro using 'SAPLSAD1' '0150'.
perform bdc_field using 'BDC_CURSOR'
'SADR-TELFX'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'SADR-NAME1'
wa_mat-name2.
perform bdc_field using 'SADR-SORTL'
wa_mat-sortl.
perform bdc_field using 'SADR-SPRAS'
wa_mat-spras.
perform bdc_field using 'SADR-STRAS'
wa_mat-stras.
perform bdc_field using 'SADR-ORT01'
wa_mat-ORT01.
perform bdc_field using 'SADR-PSTLZ'
wa_mat-pstlz.
perform bdc_field using 'SADR-ORT02'
wa_mat-ORT02.
perform bdc_field using 'SADR-LAND1'
wa_mat-land1.
perform bdc_field using 'SADR-REGIO'
wa_mat-regio.
perform bdc_field using 'SADR-TZONE'
wa_mat-tzone.
perform bdc_field using 'SADR-TELF1'
wa_mat-telf1.
perform bdc_field using 'SADR-TELFX'
wa_mat-telfx.
perform bdc_dynpro using 'SAPMF02D' '1360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'=PF03'.
*perform bdc_field using 'KNVK-NAME1'
* 'Work Address'.
*perform bdc_field using 'KNVK-ABTNR'
* 'Z001'.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAME1(02)'.
perform bdc_field using 'BDC_OKCODE'
'=LSDP'.
perform bdc_field using 'KNVK-NAME1(02)'
wa_mat-name3.
perform bdc_field using 'KNVK-ABTNR(02)'
wa_mat-abtnr1.
perform bdc_dynpro using 'SAPMF02D' '1360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'=ADRP'.
*perform bdc_field using 'KNVK-NAME1'
* 'Registered Address'.
*perform bdc_field using 'KNVK-ABTNR'
* 'Z002'.
perform bdc_dynpro using 'SAPLSAD1' '0150'.
perform bdc_field using 'BDC_CURSOR'
'SADR-TELFX'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'SADR-NAME1'
wa_mat-name4.
perform bdc_field using 'SADR-SORTL'
wa_mat-sortl1.
perform bdc_field using 'SADR-SPRAS'
wa_mat-spras1.
perform bdc_field using 'SADR-STRAS'
wa_mat-stras1.
perform bdc_field using 'SADR-ORT01'
wa_mat-ORT011.
perform bdc_field using 'SADR-PSTLZ'
wa_mat-pstlz1.
perform bdc_field using 'SADR-ORT02'
wa_mat-ORT021.
perform bdc_field using 'SADR-LAND1'
wa_mat-LAND11.
perform bdc_field using 'SADR-REGIO'
wa_mat-regio1.
perform bdc_field using 'SADR-TZONE'
wa_mat-tzone1.
perform bdc_field using 'SADR-TELF1'
wa_mat-telf11.
perform bdc_field using 'SADR-TELFX'
wa_mat-telfx1.
perform bdc_dynpro using 'SAPMF02D' '1360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'=PF03'.
*perform bdc_field using 'KNVK-NAME1'
* 'Registered Address'.
*perform bdc_field using 'KNVK-ABTNR'
* 'Z002'.
perform bdc_dynpro using 'SAPMF02D' '0360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-NAME1(03)'.
perform bdc_field using 'BDC_OKCODE'
'=LSDP'.
perform bdc_field using 'KNVK-NAME1(03)'
wa_mat-name5.
perform bdc_field using 'KNVK-PAFKT(03)'
wa_mat-pafkt.
perform bdc_dynpro using 'SAPMF02D' '1360'.
*perform bdc_field using 'BDC_CURSOR'
* 'KNVK-GBDAT'.
perform bdc_field using 'BDC_OKCODE'
'=ADRP'.
*perform bdc_field using 'KNVK-NAME1'
* 'hasu'.
perform bdc_field using 'KNVK-GBDAT'
wa_mat-gbdat.
*perform bdc_field using 'KNVK-PAFKT'
* '02'.
perform bdc_dynpro using 'SAPLSAD1' '0150'.
perform bdc_field using 'BDC_CURSOR'
'SADR-TELFX'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'SADR-NAME1'
wa_mat-name6.
**perform bdc_field using 'SADR-SORTL'
* wa_mat-sortl2.
perform bdc_field using 'SADR-SPRAS'
wa_mat-spras2.
perform bdc_field using 'SADR-STRAS'
wa_mat-stras2.
perform bdc_field using 'SADR-ORT01'
wa_mat-ORT012.
perform bdc_field using 'SADR-PSTLZ'
wa_mat-pstlz2.
perform bdc_field using 'SADR-ORT02'
wa_mat-ORT022.
perform bdc_field using 'SADR-LAND1'
wa_mat-land12.
perform bdc_field using 'SADR-REGIO'
wa_mat-regio2.
perform bdc_field using 'SADR-TZONE'
wa_mat-tzone2.
perform bdc_field using 'SADR-TELF1'
wa_mat-telf12.
perform bdc_field using 'SADR-TELFX'
wa_mat-telfx2.
perform bdc_dynpro using 'SAPMF02D' '1360'.
perform bdc_field using 'BDC_CURSOR'
'KNVK-SORTL'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
*perform bdc_field using 'KNVK-NAME1'
* 'hasu'.
*perform bdc_field using 'KNVK-GBDAT'
* '20.03.1990'.
*perform bdc_field using 'KNVK-PAFKT'
* '02'.
perform bdc_transaction using 'XD02'.
ENDLOOP.
WRITE:/'sucess number of transactiocn:-',cnt.
WRITE:/'unsuccess number of transaction:-',cnt1.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
* batch input session
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE 'A'
UPDATE 'S'
MESSAGES INTO MESSTAB.
WRITE: / 'CALL_TRANSACTION',
TCODE,
'returncode:'(I05),
L_SUBRC,
'RECORD:',
SY-INDEX.
if sy-SUBRC EQ 0 .
cnt = cnt + 1.
else.
cnt1 = cnt1 + 1.
ENDIF.
LOOP AT MESSTAB.
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.