‎2007 Jul 26 5:56 PM
Hi,
I have the following code to create the credit memo. How can I seperate the loop to perform the header once and the itemdata as no of records from the itab.
Please help me.
LOOP AT gt2_zprice INTO gs_zprice1.
PERFORM headerdata.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
PERFORM call_function.
PERFORM update_pricetable.
PERFORM errorcheckandcommit.
ENDLOOP.
Thanks,
Neelu.
‎2007 Jul 26 9:04 PM
Hi,
Check this
data : v_flg type c.
LOOP AT gt4_zprice INTO gs_zprice1.
AT NEW kunnr.
move 'Y' to v_flg.
ENDAT.
if v_flg eq 'Y'. " Check these lines
PERFORM headerdata."
clear v_flg. "
endif. "
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
ENDLOOP.
PERFORM call_function.
* PERFORM update_pricetable.
PERFORM errorcheckandcommit.
aRs
‎2007 Jul 26 5:59 PM
Use AT NEW <Header Field>.
PERFORM HEADER.
END AT.
Regards,
Amit
Reward all helpful replies.
‎2007 Jul 26 6:00 PM
HI,
When you say header there will be only one record for the header right.
you can say
loop at gt2_zprice into gs_zprice1.
at new <Field>
PERFORM headerdata.
endat.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
PERFORM call_function.
PERFORM update_pricetable.
PERFORM errorcheckandcommit.
endloop.
Message was edited by:
I Can Solve It
‎2007 Jul 26 6:05 PM
Hi,
if you are using at new , then please remember to sort gt2_zprice by <header field>
aRs
‎2007 Jul 26 8:57 PM
Hi,
Thank you all.
I changed the code like this.
LOOP AT gt4_zprice INTO gs_zprice1.
AT NEW kunnr.
PERFORM headerdata.
ENDAT.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
ENDLOOP.
PERFORM call_function.
PERFORM update_pricetable.
PERFORM errorcheckandcommit.
Now header is executing only once, but the problem is gs_zprice1 had data for all fields, after 'AT NEW KUNNR' only 'mandt vkorg vtweg spart kunnr' is having data and remaining all fields are having *'s. After ENDAT again data is comming in to gs_zprice1 automatically and item data is fine with it. Why is this happenning. Am I doing something wrong. Please help me.
gs_zprice1 has the following fields.
mandt vkorg vtweg spart kunnr matnr zcrdate zefdate
zprice3 zprice4 zquantity1 zquantity2 auart bstkd werks_d
augru xblnr vbeln
Thanks,
Neelu.
‎2007 Jul 26 9:04 PM
Hi,
Check this
data : v_flg type c.
LOOP AT gt4_zprice INTO gs_zprice1.
AT NEW kunnr.
move 'Y' to v_flg.
ENDAT.
if v_flg eq 'Y'. " Check these lines
PERFORM headerdata."
clear v_flg. "
endif. "
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
ENDLOOP.
PERFORM call_function.
* PERFORM update_pricetable.
PERFORM errorcheckandcommit.
aRs
‎2007 Jul 26 9:06 PM
You don't really want to do the rest of it, if it is a new KUNNR, right, if that is the case, then put CONTINUE after the PERFORM inside the AT NEW.
LOOP AT gt2_zprice INTO gs_zprice1.
at new kunnr.
PERFORM headerdata.
continue.
endat.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
PERFORM call_function.
* PERFORM update_pricetable.
PERFORM errorcheckandcommit.
ENDLOOP.Regards,
Rich Heilman