‎2009 Jun 17 1:31 PM
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.
‎2009 Jun 17 1:46 PM
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
‎2009 Jun 17 1:34 PM
Hi,
why are you clearing the 'itab' inside the loop? What is the required functionality?
‎2009 Jun 17 1:39 PM
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,
‎2009 Jun 17 1:35 PM
‎2009 Jun 17 1:36 PM
Hi ,
Check that your internal table is sorted by zuonr , also check that this field (zuonr) should be top in the internal table.
‎2009 Jun 17 1:36 PM
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
‎2009 Jun 17 1:48 PM
i have checked for lifnr.
it is working fine.
but when i use zuonr it not working properly
‎2009 Jun 17 1:52 PM
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.
‎2009 Jun 17 1:46 PM
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
‎2009 Jun 17 1:59 PM
‎2009 Jun 17 1:55 PM