2009 Dec 17 1:42 PM
Hello Experts,
LOOP AT IT_FINAL.
READ TABLE IT_BSEG WITH KEY BUKRS = IT_FINAL-BUKRS.
IF SY-SUBRC EQ 0.
* MOVE-CORRESPONDING IT_BSEG TO IT_FINAL.
IT_FINAL-BELNR = IT_BSEG-BELNR.
IT_FINAL-GJAHR = IT_BSEG-GJAHR.
IT_FINAL-DMBTR = IT_BSEG-DMBTR.
IT_FINAL-PSWSL = IT_BSEG-PSWSL.
IT_FINAL-ZUONR = IT_BSEG-ZUONR.
IT_FINAL-SGTXT = IT_BSEG-SGTXT.
IT_FINAL-AUFNR = IT_BSEG-AUFNR.
IT_FINAL-SHKZG = IT_BSEG-SHKZG.
IT_FINAL-HKONT = IT_BSEG-HKONT.
IT_FINAL-ALTKT = IT_BSEG-ALTKT.
ENDIF.
MODIFY IT_FINAL.
ENDLOOP.the it_final-bukrs holds the data of bkpf-bukrs, so bukrs is suppose 0001for the continuous for rows in itab_final.
like wise it_bseg-bukrs is also 0001say 5times repeated in the row...
my doubt is for the first time in the loop for it_final= 0001,it_bseg transfers the data for the first row in it.
and so when the loop iterates for the 2nd row in it_final-bukrs=0001as usual the first row from it_bseg-bukrs=0001 is transfered....so i want that,is it posssible that for each it_final-bukrs all the rows having same value as bukrs is transfered from it_bseg...
if i introduce loop inside the it_final it will create redundancy for it_final-bukrs if i am not doin so it is just giving the values of the first row from it_bseg...
is there possible way to come out of that?
plz help...ur suggestions n guidance will be highly appreciated..
thnks n regards,
Ashmita
Moderator message - Please use code tags around your code. And do not use textspeak
Edited by: Rob Burbank on Dec 17, 2009 9:22 AM
2009 Dec 17 2:24 PM
Hi Ashmita,
If I understand you correctly you want to store something like this in IT_FINAL:
FIELD1 FIELD2 FIELD3 BUKRS BELNR GJAHR .....
111111 111111 111111 B11111 1 2001
2 2002
3 2003
222222 222222 222222 B22222 4 2004
5 2005Is that it? Don't understand exactly why you would need it, but one solution would be to have in IT_FIELD one field BSEG with type TABLE OF IT_BSEG. Then for each IT_FIELD record you can have several entries in field BSEG.
Hope this helps,
Rui Dantas
Hello Experts,
LOOP AT IT_FINAL.
READ TABLE IT_BSEG WITH KEY BUKRS = IT_FINAL-BUKRS.
IF SY-SUBRC EQ 0.
* MOVE-CORRESPONDING IT_BSEG TO IT_FINAL.
IT_FINAL-BELNR = IT_BSEG-BELNR.
IT_FINAL-GJAHR = IT_BSEG-GJAHR.
IT_FINAL-DMBTR = IT_BSEG-DMBTR.
IT_FINAL-PSWSL = IT_BSEG-PSWSL.
IT_FINAL-ZUONR = IT_BSEG-ZUONR.
IT_FINAL-SGTXT = IT_BSEG-SGTXT.
IT_FINAL-AUFNR = IT_BSEG-AUFNR.
IT_FINAL-SHKZG = IT_BSEG-SHKZG.
IT_FINAL-HKONT = IT_BSEG-HKONT.
IT_FINAL-ALTKT = IT_BSEG-ALTKT.
ENDIF.
MODIFY IT_FINAL.
ENDLOOP.the it_final-bukrs holds the data of bkpf-bukrs, so bukrs is suppose 0001for the continuous for rows in itab_final.
like wise it_bseg-bukrs is also 0001say 5times repeated in the row...
my doubt is for the first time in the loop for it_final= 0001,it_bseg transfers the data for the first row in it.
and so when the loop iterates for the 2nd row in it_final-bukrs=0001as usual the first row from it_bseg-bukrs=0001 is transfered....so i want that,is it posssible that for each it_final-bukrs all the rows having same value as bukrs is transfered from it_bseg...
if i introduce loop inside the it_final it will create redundancy for it_final-bukrs if i am not doin so it is just giving the values of the first row from it_bseg...
is there possible way to come out of that?
plz help...ur suggestions n guidance will be highly appreciated..
thnks n regards,
Ashmita
Moderator message - Please use code tags around your code. And do not use textspeak
Edited by: Rob Burbank on Dec 17, 2009 9:22 AM
2009 Dec 17 2:24 PM
Hi Ashmita,
If I understand you correctly you want to store something like this in IT_FINAL:
FIELD1 FIELD2 FIELD3 BUKRS BELNR GJAHR .....
111111 111111 111111 B11111 1 2001
2 2002
3 2003
222222 222222 222222 B22222 4 2004
5 2005Is that it? Don't understand exactly why you would need it, but one solution would be to have in IT_FIELD one field BSEG with type TABLE OF IT_BSEG. Then for each IT_FIELD record you can have several entries in field BSEG.
Hope this helps,
Rui Dantas
2009 Dec 17 3:35 PM
Hi,
{SORT IT_BKPF BY BUKRS BELNR GJAHR.
LOOP AT IT_BSEG INTO IS_BSEG.
READ TABLE IT_BKPF INTO IS_BKPF WITH KEY BUKRS = IS_BSEG-BUKRS
BELNR = IS_BSEG-BELNR
GJAHR = IS_BSEG-GJAHR BINARY SEARCH.
IF SY-SUBRC EQ 0.
IT_FINAL-BELNR = IT_BSEG-BELNR.
IT_FINAL-GJAHR = IT_BSEG-GJAHR.
IT_FINAL-DMBTR = IT_BSEG-DMBTR.
IT_FINAL-PSWSL = IT_BSEG-PSWSL.
IT_FINAL-ZUONR = IT_BSEG-ZUONR.
IT_FINAL-SGTXT = IT_BSEG-SGTXT.
IT_FINAL-AUFNR = IT_BSEG-AUFNR.
IT_FINAL-SHKZG = IT_BSEG-SHKZG.
IT_FINAL-HKONT = IT_BSEG-HKONT.
IT_FINAL-ALTKT = IT_BSEG-ALTKT.
APPEND IS_FINAL TO IT_FINAL.
CLEAR IS_FINAL.
ENDIF.
ENDLOOP.}
Please try this code because always u need to loop at Item table and u need to read header table.
Regards,
Srinivas.
2009 Dec 17 3:38 PM
Please change it to IS_BSEG from IT_BSEG while passing values into FINAL table.
Edited by: Srininas on Dec 17, 2009 4:38 PM
2009 Dec 19 5:15 AM
thnks a lot sir,
but i have to sleect compnay code(bkpf-bukrs) on the selection screen and which is obligatory.
and there are some other fileds also on selection screen like psting date(bkpf-budat), order no(bseg-aufnr). and bseg-hkont.
so for this i have to go thru the header data first as my query for this is as follows............
SELECT BUKRS BLART BUDAT BLDAT MONAT
FROM BKPF INTO CORRESPONDING FIELDS OF TABLE IT_BKPF
WHERE BUKRS IN CoCd AND BUDAT IN DATE.
IF SY-SUBRC EQ 0.
SELECT BUKRS BELNR GJAHR DMBTR PSWSL ZUONR SGTXT AUFNR ALTKT SHKZG HKONT
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG FOR ALL ENTRIES IN IT_BKPF
WHERE BUKRS = IT_BKPF-BUKRS AND BELNR IN DOCNO AND HKONT IN GLAC.
IF SY-SUBRC EQ 0.
SELECT BUKRS KTEXT FROM AUFK INTO CORRESPONDING FIELDS OF TABLE IT_AUFK
FOR ALL ENTRIES IN IT_BKPF WHERE BUKRS = IT_BKPF-BUKRS.
SELECT TXT50 TXT20 FROM SKAT INTO CORRESPONDING FIELDS OF TABLE IT_SKAT
FOR ALL ENTRIES IN IT_BSEG WHERE SAKNR = IT_BSEG-ALTKT.
ENDIF.
ENDIF.
REFRESH IT_FINAL.
IT_FINAL[] = IT_BKPF[].
what should i do now ?
2009 Dec 19 8:30 AM
In your first issue use : loop with where addition.
You should try to use JOIN and FOR ALL ENTRIES in your select queries. This will help you to avoid unnecessary loop statements.
Also try to avoid INTO CORRESPONDING FIELDS statement.
Use read with binary search or index addition.
Use SAP Help to know more on these.
Edited by: Harsh Bhalla on Dec 19, 2009 2:01 PM