Skip to Content
0
Former Member
Feb 22, 2006 at 11:27 AM

uploading data from flat file to table control

108 Views

HI All,

I want to upload data to OVKK tcode using BDC. For this I wrote Z program as shown below:

REPORT ZSD_BDC_OVKK_UPLOAD

NO STANDARD PAGE HEADING LINE-SIZE 255.

*INCLUDE bdcrecx1.

DATA : BEGIN OF T_DUMMY OCCURS 0,

VAR(100) TYPE C,

END OF T_DUMMY.

DATA: BEGIN OF ITAB OCCURS 0,

  • KALSM(10) TYPE C,

* KARTV(10) TYPE C,

VKORG(4) TYPE C,

VTWEG(2) TYPE C,

SPART(2) TYPE C,

KALVG(1) TYPE C,

KALKS(1) TYPE C,

KALSM(6) TYPE C,

KARTV(4) TYPE C,

END OF ITAB.

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

DATA : v_filename TYPE string.

PARAMETER : filename LIKE rlgrap-filename OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

field_name = filename

CHANGING

file_name = filename.

START-OF-SELECTION.

v_filename = filename.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename

filetype = 'ASC'

  • has_field_separator = 'X'

TABLES

data_tab = T_DUMMY.

LOOP AT T_DUMMY.

ITAB-VKORG = T_DUMMY-VAR+0(4).

ITAB-VTWEG = T_DUMMY-VAR+5(2).

ITAB-SPART = T_DUMMY-VAR+8(2).

ITAB-KALVG = T_DUMMY-VAR+11(1).

ITAB-KALKS = T_DUMMY-VAR+13(1).

ITAB-KALSM = T_DUMMY-VAR+15(6).

ITAB-KARTV = T_DUMMY-VAR+22(4).

APPEND ITAB.

ENDLOOP.

DATA: FNAM(20) TYPE C,

IDX TYPE C.

MOVE 1 TO IDX.

LOOP AT ITAB.

REFRESH IT_BDCDATA.

PERFORM bdc_dynpro USING 'SAPML080Z' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T683V-KALSM(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=NEWL'.

PERFORM bdc_dynpro USING 'SAPML080Z' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T683V-VKORG(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SAVE'.

CONCATENATE 'V_T683V-KALSM(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-kalsm.

CONCATENATE 'V_T683V-KARTV(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-kartv.

CONCATENATE 'V_T683V-VKORG(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-vkorg.

CONCATENATE 'V_T683V-VTWEG(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-vtweg.

CONCATENATE 'V_T683V-SPART(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-spart.

CONCATENATE 'V_T683V-KALVG(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-kalvg.

CONCATENATE 'V_T683V-KALKS(' IDX ')' INTO FNAM.

PERFORM bdc_field USING FNAM

itab-kalks.

PERFORM bdc_dynpro USING 'SAPLSTRD' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'KO008-TRKORR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=LOCK'.

PERFORM bdc_field USING 'KO008-TRKORR'

'D47K919377'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T683V-VKORG(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BDC_CURSOR'

'V_T683V-VKORG(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SAVE'.

CALL TRANSACTION 'OVKK' USING IT_BDCDATA

MODE 'A'

UPDATE 'S'

MESSAGES INTO IT_BDCMSGCOLL.

IDX = IDX + 1 .

endloop.

FORM BDC_DYNPRO USING PROG SCR.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROG.

IT_BDCDATA-DYNPRO = SCR.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDFORM.

I checked in debugging mode and found that data is passed to internal table but its not uploading data to OVKK, there no data is displayed.

Please tell me solution for this.....

regards,

ravindra.