‎2006 Aug 15 1:58 PM
Hi All
I have the follow statement:
LOOP AT it_bsik.
MOVE-CORRESPONDING it_bsik TO it_xx.
READ TABLE zbseg WITH KEY bukrs = it_bsik-bukrs
belnr = it_zbsik-belnr
gjahr = it_zbsik-gjahr
buzei = it_zbsik-buzei.
MOVE-CORRESPONDING zbseg TO it_xx.
I need to move into the it_xx some fields of zbseg depending on the number of the account (zbseg-hkont)
Can I use the follow statement:
LOOP AT it_bsik.
MOVE-CORRESPONDING it_bsik TO it_xx.
READ TABLE zbseg WITH KEY bukrs = it_bsik-bukrs
belnr = it_zbsik-belnr
gjahr = it_zbsik-gjahr
buzei = it_zbsik-buzei.
MOVE-CORRESPONDING zbseg TO it_xx.
IF zbseg-hkont = '11111111'.
it_xx-field = zbseg-field.
ENDIF.
Many thanks in advance.
Cristina
‎2006 Aug 15 2:00 PM
‎2006 Aug 15 2:00 PM
‎2006 Aug 15 2:06 PM
‎2006 Aug 15 2:07 PM
HI Cristina
If the fieldname and data type if same in both
structures zbseg and it_xx, it will be copied
irrespective of the account number via
move-corresponding statement. If both fields are not
same then the explicit assignment will do the work.
Kind Regards
Eswar
‎2006 Aug 15 2:07 PM
Hi,
It would be better if you sort ZBSEG and use Binary search for performance point of view.
SORT ZBSEG by BUKRS BELNR GJAHR BUZEI.
LOOP AT it_bsik.
MOVE-CORRESPONDING it_bsik TO it_xx.
READ TABLE zbseg WITH KEY bukrs = it_bsik-bukrs
belnr = it_zbsik-belnr
gjahr = it_zbsik-gjahr
buzei = it_zbsik-buzei <b>BINARY SEARCH</b>.
MOVE-CORRESPONDING zbseg TO it_xx.
IF zbseg-hkont = '11111111'.
it_xx-field = zbseg-field.
ENDIF.
ENDLOOP.
Best regards,
Prashant
‎2006 Aug 15 2:08 PM
hi cristina,
LOOP AT it_bsik into it_xx.
*MOVE-CORRESPONDING it_bsik TO it_xx.
READ TABLE zbseg WITH KEY bukrs = it_bsik-bukrs
belnr = it_zbsik-belnr
gjahr = it_zbsik-gjahr
buzei = it_zbsik-buzei.
MOVE-CORRESPONDING zbseg TO it_xx.
IF zbseg-hkont = '11111111'.
it_xx-field = zbseg-field.
ENDIF.
‎2006 Aug 15 2:08 PM
HI,
Yes, you can move required fields based on conditions.
If we do follow programming standards, it would be better if we add few statemetns to your code. This improves the performance.
Outside the loop, we have to sort.
<b>SORT ZBSEG BY BELNR GJAHR BUZEI.</b>
<b>CLEAR : ZBSEG.</b>
READ TABLE zbseg WITH KEY bukrs = it_bsik-bukrs
belnr = it_zbsik-belnr
gjahr = it_zbsik-gjahr
buzei = it_zbsik-buzei
<b>BINARY SEARCH.</b>
MOVE-CORRESPONDING zbseg TO it_xx.
IF zbseg-hkont = '11111111'.
it_xx-field = zbseg-field.
ENDIF.
Regards,
Sailaja.
‎2006 Aug 15 2:12 PM
Surely you can use the code but just wanted to point out to you that irrespective of your IF condition the field in it_xx-field would have the value from zbseg on successful read.
Regards
Anurag