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

Validation for kunnr

Former Member
0 Likes
2,151

Hi experts,

i am trying to upload the values from flat file to ztable but

the reuirement is, the records should checked with kna1 table if the kunnr exist in kna1 then only it should get update into ztable

TYPES: BEGIN OF TY_ITAB,

F(3) TYPE C,

F1(8) TYPE N,

F2(8) TYPE N,

F3(10) TYPE C,

F4(2) TYPE C,

F5(5) TYPE C,

F6 TYPE zvbill-RATEMULTIPLE,

F7 TYPE zvbill-RATEDIVISOR,

F8(22) TYPE C,

F9(30) TYPE C,

F10 TYPE zvbill-BILLAMOUNT,

F11(30) TYPE C,

F12 TYPE D,

F13(5) TYPE C,

F14(15) TYPE C,

F15(4) TYPE C,

F16(4) TYPE C,

F17 TYPE C,

F18 TYPE D,

END OF TY_ITAB.

DATA: IT_ITAB1 TYPE TY_ITAB OCCURS 1 WITH HEADER LINE.

DATA: IT_ITAB TYPE STANDARD TABLE OF TY_ITAB INITIAL SIZE 1,

WA_ITAB TYPE TY_ITAB.

parameters: P_FNAME LIKE RLGRAP-FILENAME,

UNIXFILE LIKE RLGRAP-FILENAME.

DATA: V_FNAME TYPE STRING.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FNAME

.

START-OF-SELECTION.

MOVE P_FNAME TO V_FNAME.

*IF WA_STR-DELIM IS INITIAL.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FNAME

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • 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_ITAB

  • 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_itab into wa_itab.

read table it_itab into wa_itab with key f3 = wa_itab-f3.

SELECT kunnr FROM KNA1 INTO CORRESPONDING FIELDS OF table IT_ITAB1

for all entries in it_itab WHERE KUNNR = it_itab-f3.

but data is not coming to the it_itab1

please help me

Title edited by: Alvaro Tejada Galindo on Jun 12, 2008 12:26 PM

Hi experts,

i am trying to upload the values from flat file to ztable but

the reuirement is, the records should checked with kna1 table if the kunnr exist in kna1 then only it should get update into ztable

TYPES: BEGIN OF TY_ITAB,

F(3) TYPE C,

F1(8) TYPE N,

F2(8) TYPE N,

F3(10) TYPE C,

F4(2) TYPE C,

F5(5) TYPE C,

F6 TYPE zvbill-RATEMULTIPLE,

F7 TYPE zvbill-RATEDIVISOR,

F8(22) TYPE C,

F9(30) TYPE C,

F10 TYPE zvbill-BILLAMOUNT,

F11(30) TYPE C,

F12 TYPE D,

F13(5) TYPE C,

F14(15) TYPE C,

F15(4) TYPE C,

F16(4) TYPE C,

F17 TYPE C,

F18 TYPE D,

END OF TY_ITAB.

DATA: IT_ITAB1 TYPE TY_ITAB OCCURS 1 WITH HEADER LINE.

DATA: IT_ITAB TYPE STANDARD TABLE OF TY_ITAB INITIAL SIZE 1,

WA_ITAB TYPE TY_ITAB.

parameters: P_FNAME LIKE RLGRAP-FILENAME,

UNIXFILE LIKE RLGRAP-FILENAME.

DATA: V_FNAME TYPE STRING.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FNAME

.

START-OF-SELECTION.

MOVE P_FNAME TO V_FNAME.

*IF WA_STR-DELIM IS INITIAL.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FNAME

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • 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_ITAB

  • 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_itab into wa_itab.

read table it_itab into wa_itab with key f3 = wa_itab-f3.

SELECT kunnr FROM KNA1 INTO CORRESPONDING FIELDS OF table IT_ITAB1

for all entries in it_itab WHERE KUNNR = it_itab-f3.

but data is not coming to the it_itab1

please help me

Title edited by: Alvaro Tejada Galindo on Jun 12, 2008 12:26 PM

11 REPLIES 11
Read only

Former Member
0 Likes
1,740

Make sure your customer number has the leading zero's by using CONVERSION_EXIT_ALPHA_INPUT.

Regards,

John.

Read only

Former Member
0 Likes
1,740

hii

which file you are uploading?text file or excel file??because your code is right so data should come if text file is there.

thx

twinkal

Read only

0 Likes
1,740

data is coming to internal table succeessfully from text file

but the problem is validation before updating ztable

Read only

Former Member
0 Likes
1,740

when selecting from KNA1, why are you moving into corresponding fields of your itab? do you need that data? I thought your requirement was to just validate that KUNNR exists.

btw, select into corresponding fields is lazy coding and inefficient.

you are looping through itab1 into a work area and then READING itab1 into your work area? that doesn't make sense.

then selecting from KNA1 based on that work area-kunnr BUT you are trying to select back into itab1.

you have some fundamental problems with the Select and Validation code.

Read only

0 Likes
1,740

the coding is wrong and i have changed like this

SELECT kunnr FROM KNA1 INTO table IT_ITAB1

for all entries in it_itab WHERE KUNNR = it_itab-f3.

give me the correct code pls

Edited by: SRI ABAPER on Jun 12, 2008 3:20 PM

Read only

0 Likes
1,740

you're going to have to look elsewhere from me if you expect someone to give you the code.

I have no problems helping on SDN & other forums, but feel that, especially for very basic concepts, it's better for the developer to figure out the specifics. that way, they can apply that new knowledge from now on.

Read only

0 Likes
1,740

thanku robert

in the debugging i get to know the data is coming to it_itab

but data is not coming to i_kunnr

the problem in select statement only

Read only

0 Likes
1,740

Hi,

Have you used the function CONVERSION_EXIT_ALPHA_INPUT while populating the field itab-kunnr from the file.

also make sure that the itab-kunnr is defined as kna1-kunnr

i.e data : begin of data itab occurs 0,

kunnr like kna1-kunnr,

...,

...,

end of itab.

regards,

Advait

Read only

0 Likes
1,740

Eclectic/Megha's answer looks good. implement that and debug the Select on KNA1 to make sure you are getting that data.

then debug the Loop -> Read statement to make sure you are getting the appropriate customer. if not, it may be a formatting problem as the above mentioned.

Read only

megha_h
Participant
0 Likes
1,740

Hi,

use following code-

(it_itab is polupated first) then,

select kunnr

from kna1

into table i_kunnr

for all entries in it_itab

where kunnr = it_itab-kunnr.

loop at it_tab into wa_itab.

read table i_kunnr with key kunnr = wa_itab-kunnr.

if sy-subrc eq 0.

  • update z table here

endif.

endloop.

<REMOVED BY MODERATOR>

Regards

Megha

Edited by: Alvaro Tejada Galindo on Jun 12, 2008 12:26 PM

Read only

Former Member
0 Likes
1,740

Hi,

in the debugging i get to know the data is coming to it_itab

but data is not coming to i_kunnr