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

Read table statement

Former Member
0 Likes
799

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
772

Yes, You can use that.

Cheers

VJ

7 REPLIES 7
Read only

Former Member
0 Likes
773

Yes, You can use that.

Cheers

VJ

Read only

0 Likes
772

Many Thanks VJ !

Read only

Former Member
0 Likes
772

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

Read only

Former Member
0 Likes
772

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

Read only

Former Member
0 Likes
772

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.

Read only

Former Member
0 Likes
772

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.

Read only

Former Member
0 Likes
772

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