Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

uploading data from flat file to table control

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Look at the following link you will find some good example of Table control.

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

Here you need to take care to which line of table control you are populating the data.

Make sure to take care of page down in table control.

*********Try Call Transaction in MODE 'N'.

Check your OK_CODE once again.

Try to give BACk also after saving.

The Table control is mainly used to update no.of line items at one shot. No need to come BACK for each and every record.

Try to do recording in SHDB once again and see the changes closely.

***********

Thanks.

If this helps you reward with points.

Message was edited by: KDeepak

Message was edited by: KDeepak

0 Kudos

Hi,

For testing purpose, I am uploading a single record, that also not getting uploaded....

rgds,

ravindra.

0 Kudos

Hello,

I think the problem is one might be update 'S' is not required. And problem too is because you are calling it in a loop it is not waiting so try to put some wait for 2 seconds statement before you are calling the transaction each time.

Regards,

Shekhar Kulkarni

Former Member
0 Kudos

Hi,

First declare your field IDX as a numeric and not as

a character and with a length of 2.

Also after every single entry U need to press the

BACK , which I think is missing.

Try and record the transaction in SHDB once again.

Regards,

GSR.

0 Kudos

Hi Ravindra ,

In table Control , You need to increase the index for line items , while Incrementing the index after one point ( may be Index =9 or 12 ) after that the index will not increased so then You need to pass same index. check with dummy data in the time of recording .

then put condition if IDX > 9.

IDX = 9.

else.

IDX = IDX + 1.

endif.

regards,

Ranadheer.

Former Member
0 Kudos

Ravindra - you're using the wrong program name. Try SAPL080Z instead of SAPML080Z.

Since you are using mode 'A', you should be able to see any further error messages that come up.

Rob