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

at new command

Former Member
0 Likes
991

hi

im using at new command in a loop and i want to put the data in a variable but the data in the work area wont appear coz of the at new command, can sombody tell me how i can move the data in the variable using at new or any other alternative method

loop at itrans into wa_trans.

at new zrep_id.

move wa_trans-tabname to tabname.

endat.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
954

Hi

when we use at new command

first we need to create workarea with the same structure as wa_trans.

ex: we created wa_trans1.

loop at itrans into wa_trans.

wa_trans1 = wa_trans.

at new zrep_id.

move wa_trans1-tanbname to tabname.

clear wa_trans.

endat.

endloop.

try this it will work

10 REPLIES 10
Read only

Former Member
0 Likes
954

HI,

DEFINE WORK AREA FIRST WA.

LOOP AT ITAB.

WA = ITAB.

AT NEW.

V_VARIABLE = WA-FIELD.

END AT.

PANKAJ

Read only

Former Member
0 Likes
954

Hi try this.

data v_tabname type trans-tabname .

loop at itrans into wa_trans.

at new zrep_id.

v_tabname = wa_trans-tabname .

endat.

endloop.

pankaj

Read only

Former Member
0 Likes
954

Hi

Please try as below:

data: l_index type sy-tabix.
loop at itrans into wa_trans.
     l_index = sy-tabix.
     at new zrep_id.
        read table itrans into wa_trans index l_index.
        move wa_trans-tabname to tabname.
     endat.
endloop.

Kind Regards

Eswar

Read only

0 Likes
954

thanks for the replies

Read only

Former Member
0 Likes
954

just check this.

regards,

vijay.

**************************************************

<b>data: g_flag type c.</b>

loop at itrans into wa_trans.

at new zrep_id.

*move wa_trans-tabname to tabname.

<b>g_flag = x.</b>

endat.

<b>if g_flag = 'X'.

move wa_trans-tabname to tabname.

endif.</b>

<b>at end of zrep_id.

clear g_flag.

endat.</b>

endloop.

Read only

Former Member
0 Likes
954

u can also use on change of.

santhosh

Read only

Former Member
0 Likes
954

hi

good

go through this example

REPORT demo_extract_at_new.

DATA: t1(4) TYPE c, t2 TYPE i.

FIELD-GROUPS: header.

INSERT t2 t1 INTO header.

t1 ='AABB'. t2 = 1. EXTRACT header.

t1 ='BBCC'. t2 = 2. EXTRACT header.

t1 ='AAAA'. t2 = 2. EXTRACT header.

t1 ='AABB'. t2 = 1. EXTRACT header.

t1 ='BBBB'. t2 = 2. EXTRACT header.

t1 ='BBCC'. t2 = 2. EXTRACT header.

t1 ='AAAA'. t2 = 1. EXTRACT header.

t1 ='BBBB'. t2 = 1. EXTRACT header.

t1 ='AAAA'. t2 = 3. EXTRACT header.

t1 ='AABB'. t2 = 1. EXTRACT header.

SORT BY t1 t2.

LOOP.

AT FIRST.

WRITE 'Start of LOOP'.

ULINE.

ENDAT.

AT NEW t1.

WRITE / ' New T1:'.

ENDAT.

AT NEW t2.

WRITE / ' New T2:'.

ENDAT.

WRITE: /14 t1, t2.

AT END OF t2.

WRITE / 'End of T2'.

ENDAT.

AT END OF t1.

WRITE / 'End of T1'.

ENDAT.

AT LAST.

ULINE.

ENDAT.

ENDLOOP.

thanks

mrutyun^

Read only

Former Member
0 Likes
954

Hi Anjali,

when you use at new statement, in the structure till that field only available.

for ex:

u are haivng IT with 5 fileds and

you r using 3rd field in your at new statement,

in your structure only 1, 2 and 3rd fields only get filled.

so u need to read that paricular table again using current index.

loop at it_tab.

l_index = sy-tabix.

at new f3.

  • you can use f1, f2 and f3 directly

read table it_tab index l_index.

if sy-subrc = 0.

  • use it_tab-f4 and it_tab-f5

endif.

endat.

endloop.

-Anu

Message was edited by: Anupama Reddy

Read only

Former Member
0 Likes
954

Hi Anjali,

One basic fundamental is u can't do any thing when u are using at new and end at b'coz all the remaining fields will be filled with ####

so u have to follow the below process.

declare a flag say data : v_flag type c.

<b>loop at itab.</b>

<b>At new ****</b>

flag = 'x'.

<b>end at.</b>

<b>if flag = 'x'.</b>

v_variable = wa-variable.

clear v_flag.

<b>endif.</b>

<b>endloop.</b>

Hope this will surely solvy ur problem

Read only

Former Member
0 Likes
955

Hi

when we use at new command

first we need to create workarea with the same structure as wa_trans.

ex: we created wa_trans1.

loop at itrans into wa_trans.

wa_trans1 = wa_trans.

at new zrep_id.

move wa_trans1-tanbname to tabname.

clear wa_trans.

endat.

endloop.

try this it will work