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 Functionality

Former Member
0 Likes
1,103

At new is not functionig.

where i was wrong in this code.

LOOP AT itab WHERE zuonr+0(1) EQ 'S'.

AT NEW zuonr.

READ TABLE it_prin WITH KEY bukrs = itab-bukrs

gsber = itab-gsber

xref2 = itab-zuonr.

IF sy-subrc EQ 0.

itab-prdeb = it_prin-dmbtr.

MODIFY itab TRANSPORTING prdeb.

clear:itab,it_prin.

ENDIF.

ENDAT.

ENDLOOP.

Suggest me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,070

Hi Jitendra,

When you use AT NEW, then if anything change on left side of ZUONR, it will trigger. So my suggestion will be make ZUONR field as first fireld if possible.

Declare accordingly. If ZUONR has to be first field, then give complete structure instead of like ITAB.

data: itab1 like itab occurs 0 with header line,

wa_data like itab .

itab1[] = itab[].

delete itab1 where zuonr+0(1) ne 'S'.

sort itab1 by zuonr.

sort it_prin by bukrs gsber xref2.

LOOP AT itab1 .

move itab1 to wa_data.

AT NEW zuonr.

READ TABLE it_prin WITH KEY bukrs = wa_data-bukrs

gsber = wa_data-gsber

xref2 = wa_data-zuonr binary search.

IF sy-subrc EQ 0.

wa_data-prdeb = it_prin-dmbtr.

MODIFY itab1 from wa_data TRANSPORTING prdeb.

clear:itab1,

wa_data

it_prin.

ENDIF.

ENDAT.

ENDLOOP.

Regards,

Anil

10 REPLIES 10
Read only

Former Member
0 Likes
1,070

Hi,

why are you clearing the 'itab' inside the loop? What is the required functionality?

Read only

0 Likes
1,070

Although that statement is omitted : the result is same.

whenever new zuonr comes then only i am assigning value.

but it is taking all posibilities.

Thanks,

Read only

Former Member
0 Likes
1,070

You cant use AT NEW with WHERE this way...

Read only

Former Member
0 Likes
1,070

Hi ,

Check that your internal table is sorted by zuonr , also check that this field (zuonr) should be top in the internal table.

Read only

former_member212005
Active Contributor
0 Likes
1,070

Nothing seems to be wrong with the code...

Put a break point at the read statement and check...also enusre that you are sorting the internal table before using proper field..

Debug and look for errors.

Edited by: Vin on Jun 17, 2009 2:37 PM

Read only

0 Likes
1,070

i have checked for lifnr.

it is working fine.

but when i use zuonr it not working properly

Read only

0 Likes
1,070

HI,

If AT NEW need's to triggered only if any change in the ZUONR then this field should be the first Field of Internal table.

If it not the first field then any change in the fields before this ZUONR then AT NEW will get triggered.

Or You can use ON CHANGE OF ZUONR -- This trigger only if any change inthis field irrespective of any change in the previous fields.

Read only

Former Member
0 Likes
1,071

Hi Jitendra,

When you use AT NEW, then if anything change on left side of ZUONR, it will trigger. So my suggestion will be make ZUONR field as first fireld if possible.

Declare accordingly. If ZUONR has to be first field, then give complete structure instead of like ITAB.

data: itab1 like itab occurs 0 with header line,

wa_data like itab .

itab1[] = itab[].

delete itab1 where zuonr+0(1) ne 'S'.

sort itab1 by zuonr.

sort it_prin by bukrs gsber xref2.

LOOP AT itab1 .

move itab1 to wa_data.

AT NEW zuonr.

READ TABLE it_prin WITH KEY bukrs = wa_data-bukrs

gsber = wa_data-gsber

xref2 = wa_data-zuonr binary search.

IF sy-subrc EQ 0.

wa_data-prdeb = it_prin-dmbtr.

MODIFY itab1 from wa_data TRANSPORTING prdeb.

clear:itab1,

wa_data

it_prin.

ENDIF.

ENDAT.

ENDLOOP.

Regards,

Anil

Read only

0 Likes
1,070

Thank you very much.

Read only

tarangini_katta
Active Contributor
0 Likes
1,070

Hi Jitendhar,

Then tyr to use 'on Change of'

Thanks,