Application Development and Automation 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: 
Read only

what is wrong with my code.....

Former Member
0 Likes
430

hello experts,

can anyone guide me ... what is wrong with my code... y i am not getting the data into it_sdata intenal table.... y all those performs r not assigning the data....

y the select statement is not working... I am getting the data into it_ldata internal table but after select statement i am not getting the data into IT_SDATA....

report ZCUSTTEST

no standard page heading line-size 255.

*include bdcrecx1.

tables: knvv, lfa1.

data: begin of it_ldata occurs 0,

kunnr like knvv-kunnr,

lifnr like lfa1-lifnr,

end of it_ldata.

data: begin of it_sdata occurs 0,

kunnr like knvv-kunnr,

  • lifnr like knvv-lifnr,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

end of it_sdata.

include bdcrecx1.

start-of-selection.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\Administrator\Desktop\cust.txt'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_ldata

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at it_ldata.

if it_ldata-kunnr <> ' '.

select kunnr vkorg vtweg spart from knvv into table it_sdata where kunnr = it_ldata-kunnr.

append it_sdata.

endif.

perform open_group.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=NEWL'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-AUART(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'V_EDSDC-KUNNR(01)'

'it_sdata-kunnr'.

perform bdc_field using 'V_EDSDC-LIFNR(01)'

'it_ldata-lifnr'.

perform bdc_field using 'V_EDSDC-VKORG(01)'

'it_sdata-vkorg'.

perform bdc_field using 'V_EDSDC-VTWEG(01)'

'it_sdata-vtweg'.

perform bdc_field using 'V_EDSDC-SPART(01)'

'it_sdata-spart'.

perform bdc_field using 'V_EDSDC-AUART(01)'

'ZOR'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_transaction using 'VOE2'.

perform close_group.

endloop.

I really appreciate your anticipation

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
399

Hello Nitesha,

I guess problem might be your select query :

data : it_sldata like it_sdata occurs 0 with header line.

loop at it_ldata.

if it_ldata-kunnr <> ' '.

refresh : it_sdata.

clear : it_sdata.

<b>select kunnr

vkorg

vtweg

spart from knvv

into table it_sdata

where kunnr = it_ldata-kunnr.

loop at it_sdata.

move it_sdata to it_sldata.

append it_sldata.

endloop.

endif.</b>

see every record of it_ldata ,your select query getting and after second record previous record of it_sdata is refreshing,so keep one more internal table and move the data into internal table..

perform open_group.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=NEWL'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-AUART(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'V_EDSDC-KUNNR(01)'

'it_sdata-kunnr'.

perform bdc_field using 'V_EDSDC-LIFNR(01)'

'it_ldata-lifnr'.

perform bdc_field using 'V_EDSDC-VKORG(01)'

'it_sdata-vkorg'.

perform bdc_field using 'V_EDSDC-VTWEG(01)'

'it_sdata-vtweg'.

perform bdc_field using 'V_EDSDC-SPART(01)'

'it_sdata-spart'.

perform bdc_field using 'V_EDSDC-AUART(01)'

'ZOR'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_transaction using 'VOE2'.

perform close_group.

endloop.

Thanks

Seshu

2 REPLIES 2
Read only

alejandro_bindi
Active Contributor
0 Likes
399

As I see you're populating it_ldata from file cust.txt which has customer numbers, then you're trying to retrieve customer related data from table KNVV into it_sdata...

Some items to check

1) about the file cust.txt...it has exactly 20 chars per line?

For example

11111111112222222222

If yes, your program would load it_ldata with '1111111111' as kunnr and '2222222222' as lifnr.

If not, maybe you need to complete with zeros using for example CONVERSION_EXIT_ALPHA_INPUT function module.

2) Does the kunnr '1111111111' (following this example) exist in table KNA1? Are there any records in KNVV table with this key (check in SE16).

Also, a couple of suggestions (once you solve the problem):

1) If possible, use SELECT...FOR ALL ENTRIES instead of SELECT inside loop. Then loop it_sdata processing different kunnr's.

2) Remove append it_sdata, it's not necessary since you're selecting directly inside the internal table.

Regards, post again if you need further help.

Please reward points if helpful.

Read only

Former Member
0 Likes
400

Hello Nitesha,

I guess problem might be your select query :

data : it_sldata like it_sdata occurs 0 with header line.

loop at it_ldata.

if it_ldata-kunnr <> ' '.

refresh : it_sdata.

clear : it_sdata.

<b>select kunnr

vkorg

vtweg

spart from knvv

into table it_sdata

where kunnr = it_ldata-kunnr.

loop at it_sdata.

move it_sdata to it_sldata.

append it_sldata.

endloop.

endif.</b>

see every record of it_ldata ,your select query getting and after second record previous record of it_sdata is refreshing,so keep one more internal table and move the data into internal table..

perform open_group.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=NEWL'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-AUART(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'V_EDSDC-KUNNR(01)'

'it_sdata-kunnr'.

perform bdc_field using 'V_EDSDC-LIFNR(01)'

'it_ldata-lifnr'.

perform bdc_field using 'V_EDSDC-VKORG(01)'

'it_sdata-vkorg'.

perform bdc_field using 'V_EDSDC-VTWEG(01)'

'it_sdata-vtweg'.

perform bdc_field using 'V_EDSDC-SPART(01)'

'it_sdata-spart'.

perform bdc_field using 'V_EDSDC-AUART(01)'

'ZOR'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_dynpro using 'SAPL0VED' '0100'.

perform bdc_field using 'BDC_CURSOR'

'V_EDSDC-KUNNR(02)'.

perform bdc_field using 'BDC_OKCODE'

'=BACK'.

perform bdc_transaction using 'VOE2'.

perform close_group.

endloop.

Thanks

Seshu