‎2009 Apr 29 6:06 PM
Hi all
My JTAB has following definition
DATA: BEGIN OF JTAB OCCURS 0,
BELNR_AWKEY LIKE RSEG-BELNR,
GJAHR_AWKEY LIKE RSEG-GJAHR,
END OF JTAB.
My ITAB has following definition
DATA: BEGIN OF ITAB OCCURS 0,
EBELN LIKE RSEG-EBELN,
END OF ITAB.
Now from RESG table for all entries in JTAB I have to select EBELN and put in ITAB-EBELN
For that I wrote following select query
SELECT SINGLE EBELN FROM RSEG INTO ITAB-EBELN
WHERE BELNR = JTAB-BELNR_AWKEY
AND GJAHR = JTAB-GJAHR_AWKEY.
But I donu2019t get any values in ITAB-EBELN.
and my ITAB is always empty...
Does any body know if I am missing something?
Regards,
Jessica Sam
‎2009 Apr 29 6:11 PM
Hi,
First populate JTAB
if JTAB is not initial.
SELECT SINGLE EBELN FROM RSEG INTO ITAB-EBELN
for all entries in JTAB
WHERE BELNR = JTAB-BELNR_AWKEY
AND GJAHR = JTAB-GJAHR_AWKEY.
endif.
Regards
Krishna
‎2009 Apr 29 6:12 PM
Hi,
Try this code
SELECT EBELN FROM RSEG
INTO TABLE ITAB
FOR ALL ENTRIES IN JTAB
WHERE BELNR = JTAB-BELNR_AWKEY
AND GJAHR = JTAB-GJAHR_AWKEY.
‎2009 Apr 29 6:13 PM
Try this:
SELECT EBELN FROM RSEG INTO table ITAB
for all entries in JTAB
WHERE BELNR = JTAB-BELNR_AWKEY
AND GJAHR = JTAB-GJAHR_AWKEY.
Regards,
Michael
‎2009 Apr 29 6:22 PM
Thanks a lot for everybosy who answered the thread ...........but unfortunately i am still struggling........I tried all the select queries suggested by al of you....but they dont work.
I dont see any data being populated in ITAB-EBELN.
but if i really look in the RSEG table from SE11 t-code and look for EBELN values based on BELNR and GJAHR in JTAB i find entries.
that means the select query i am witing is wrong..there is data in table but i am unable to pick.
some one please help...
Regards,
Jessica Sam
‎2009 Apr 29 7:12 PM
Did you check in the debugger that the JTAB is filled correctly? If the BELNR in RSEG has leading zeros you have to make sure that your JTAB entries do contain leading zeros as well and vice versa. Since BELNR is a character 10 field the entries in both tables need to be an exact match.
Hope that helps,
Michael
‎2009 Apr 29 7:30 PM
Did you check in the debugger that the JTAB is filled correctly? If the BELNR in RSEG has leading zeros you have to make sure that your JTAB entries do contain leading zeros as well and vice versa. Since BELNR is a character 10 field the entries in both tables need to be an exact match.
Hope that helps,
Michael
Thanks for replying back Michael
I checked indebugger and JTAB values have leading zeros. and for all entries in JTAB if i go and check in RESG table i find entries for EBELN but my ITAB is not getting populated
I found that for one entry of JTAB-BELNR i have more than one record in RSEG table
but for combination of JTAB-BELNR and JTAB-GJAHR i exactly have one record in the database table RESG, but my select query is not picking the values and finally always my ITAB-EBELN remains empty.
Any thoughts what elese could be reason.
Reagrds
Jessica Sam
‎2009 Apr 29 7:59 PM
Since our RSEG table doesn't have any entries I created the following ones:
BELNR GJAHR EBELN
0000000001 2009 4500000000
0000000002 2009 4500000001
0000000003 2009 4500000002
0000000004 2009 4500000003
I wrote the following report and it does select two entries:
TYPES: BEGIN OF ty_jtab,
belnr_awkey LIKE rseg-belnr,
gjahr_awkey LIKE rseg-gjahr,
END OF ty_jtab.
TYPES: BEGIN OF ty_itab,
ebeln LIKE rseg-ebeln,
END OF ty_itab.
DATA: lt_jtab TYPE TABLE OF ty_jtab,
ls_jtab TYPE ty_jtab,
lt_itab TYPE TABLE OF ty_itab.
ls_jtab-belnr_awkey = '0000000001'.
ls_jtab-gjahr_awkey = '2009'.
APPEND ls_jtab TO lt_jtab.
ls_jtab-belnr_awkey = '0000000002'.
ls_jtab-gjahr_awkey = '2009'.
APPEND ls_jtab TO lt_jtab.
SELECT ebeln FROM rseg INTO TABLE lt_itab
FOR ALL ENTRIES IN lt_jtab
WHERE belnr = lt_jtab-belnr_awkey
AND gjahr = lt_jtab-gjahr_awkey.
BREAK-POINT.
I just changed the data definition because I usually don't use tables with header lines.
Check what is different to the select you do, You should also add a check if lt_jtab is not initial, because if it is it will select EVERY entry from RSEG.
Hope that helps,
Michael
‎2009 Apr 29 8:17 PM
Thanks Michel and Srinivas..I was not appending the itab and was not looping through jtab.
that was the mistake.
now it is solved..
But i have one one more question
my ITAB has fields A B C D
and for all entries in ITAB i have to concatenate B C and D and put in A
example:-
ITAB
A B C D
eee fff ggg
kkk lll mmm
Now after appending my ITAB should be
A B C D
eeefffggg eee fff ggg
kkklllmmm kkk lll mmm
so i said
loop at itab.
concatenate itab-b itab-c itab-d into itab-a
append itab.
endloop.
again it doesnt work
any thoughts ..no values in field A
‎2009 Apr 29 8:25 PM
Going back to my example:
TYPES: BEGIN OF ty_itab,
a TYPE any,
b TYPE any,
c TYPE any,
d TYPE any,
END OF ty_itab.
DATA: lt_itab TYPE TABLE OF ty_itab.
FIELD-SYMBOLS: <fs_itab> type ty_itab.
LOOP AT lt_itab ASSIGNING <fs_itab>.
CONACTENATE <fs_itab>-b <fs_itab>-c <fs_itab>-d INTO <fs_itab>-a.
ENDLOOP.
This will fill a with a concatenation of b,c and d
I am using TYPE any but you can replace that with the actual data type you are using.
Regards,
Michael
‎2009 Apr 29 9:22 PM
you might want to use 'modify' instead of 'append', since append would add new records to the table without updating the old ones...
‎2009 Apr 29 6:20 PM
Hi Sam,
First populate JTAB
if JTAB is not initial. "check this before using for all entries
SELECT EBELN FROM RSEG INTO TABLE ITAB
FOR ALL ENTRIES IN JTAB
WHERE BELNR = JTAB-BELNR_AWKEY
AND GJAHR = JTAB-GJAHR_AWKEY.endif.
ENDIF.
Regards,
Prabhudas
‎2009 Apr 29 7:42 PM
Hi Jessica,
Did you try to append the record to the actual table using "APPEND ITAB".
There is a difference between the header line ITAB-EBELN and table ITAB[]. For all the other select statements provided in the answers you would have to loop at ITAB to populate ITAB-EBELN. After looking at all the answers thats the only thing that might be keeping you from seeing the values in debugging.
Regards,
Rohit