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

taking only last record

Former Member
0 Likes
944

hi all,

i have a flat file and in that there r multiple records of type '3' and in that i want to move some text which is at t_data-fld+359(80) to w_data-zmardesc.

the below code is working fine but it is moving the last record text only. but i want for the first record.

plz suggest what to do.

IF T_DATA-FLD+1(1) = '3'.

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

ENDIF.

regards,

siri.

Message was edited by:

sireesha yalamanchili

1 ACCEPTED SOLUTION
Read only

former_member187255
Active Contributor
0 Likes
907

If ur using loop then Check something like this.....

IF SY-TABIX EQ 1.
IF T_DATA-FLD+1(1) = '3'.
W_DATA-ZMARDESC = T_DATA-FLD+359(80).
ELSE.
EXIT.
ENDIF.

Hope this helps...

hi all,

i have a flat file and in that there r multiple records of type '3' and in that i want to move some text which is at t_data-fld+359(80) to w_data-zmardesc.

the below code is working fine but it is moving the last record text only. but i want for the first record.

plz suggest what to do.

IF T_DATA-FLD+1(1) = '3'.

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

ENDIF.

regards,

siri.

Message was edited by:

sireesha yalamanchili

7 REPLIES 7
Read only

Former Member
0 Likes
907

try this..

<b>data : flag(1).</b>

IF T_DATA-FLD+1(1) = '3'.

<b>if flag ne 'X'.</b>

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

<b>flag = 'X'.</b>

ENDIF.

endif.

Message was edited by:

Chandrasekhar Jagarlamudi

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

former_member187255
Active Contributor
0 Likes
908

If ur using loop then Check something like this.....

IF SY-TABIX EQ 1.
IF T_DATA-FLD+1(1) = '3'.
W_DATA-ZMARDESC = T_DATA-FLD+359(80).
ELSE.
EXIT.
ENDIF.

Hope this helps...

Read only

0 Likes
907

Hi chandras thank you,

i am not using loop.

regards,

siri.

Read only

0 Likes
906

try this

<b>data : flag(1).</b>

IF T_DATA-FLD+1(1) = '3'.

<b>if flag ne 'X'.</b>

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

<b>flag = 'X'.</b>

ENDIF.

endif.

Read only

0 Likes
906

hi,

what is this flag concept could you plz explain.

regards,

siri.

Read only

0 Likes
906

first time the FLAG will be space ,

IF T_DATA-FLD+1(1) = '3'.   " enters IF condition when condition met
if flag ne 'X'.                        " as flag is SPACE for first time it will continue,
                                         "second time when it comes flag will be X , so it will
                                         "not enter and you will have the first record data 
W_DATA-ZMARDESC = T_DATA-FLD+359(80).
flag = 'X'.
ENDIF.
endif.

Read only

rodrigo_paisante3
Active Contributor
0 Likes
906

Helo, you can do like this:

<b>READ TABLE T_DATA INDEX 1</b>

IF T_DATA-FLD+1(1) = '3'.

W_DATA-ZMARDESC = T_DATA-FLD+359(80).

ENDIF.

Or if you need, use the sort command before the read.

Regards

Message was edited by:

Rodrigo Paisante

Message was edited by:

Rodrigo Paisante