11-07-2007 6:37 PM
Hi,
My current program creates Sales orders based on the function 'SD_SALESDOCUMENT_CREATE' and at new kunnr it creates a new SO. User wants me to add the functionality to create separate SO for the same customer if sales area is different. Can you please help me to add this functionality.
Kunnr Sorg Distri Divi
1011 300 20 01
1011 300 20 01
1011 300 10 01
1011 300 10 01
2011 300 10 01
For Ex:
I need 3 SO's, one for records 1 and 2, Two for records 3 and 4, Three for record 5.
Please help me.
Thanks,
Veni.
WHEN 'SORD'.
DESCRIBE TABLE gt_zprice LINES lv_cnt.
DO lv_cnt TIMES.
lv_index = sy-index + 4.
READ LINE lv_index FIELD VALUE chbox.
IF chbox = 'X'.
READ TABLE gt_zprice INTO gs_zprice1 INDEX sy-index.
IF sy-subrc EQ 0.
gs_zprice1-index = sy-index.
APPEND gs_zprice1 TO gt2_zprice.
CLEAR gs_zprice1.
ENDIF.
ENDIF.
CLEAR chbox.
ENDDO.
gt4_zprice[] = gt2_zprice[].
LOOP AT gt4_zprice INTO gs_zprice1.
IF gs_zprice1-crmemo IS INITIAL.
AT NEW kunnr.
MOVE 'Y' TO lv_flg.
ENDAT.
IF lv_flg EQ 'Y'.
PERFORM headerdata.
PERFORM texts.
CLEAR lv_flg.
ENDIF.
IF gs_zprice1-eohqty IS INITIAL.
CONTINUE.
ENDIF.
PERFORM itemdata.
APPEND gs_zprice1 TO gt3_zprice.
CLEAR gs_zprice1.
AT END OF kunnr.
PERFORM call_function.
PERFORM update_pricetable.
PERFORM errorcheckandcommit.
REFRESH gt2_zprice.
CLEAR chbox.
REFRESH partner.
REFRESH item.
REFRESH itemx.
REFRESH lt_schedules_in.
REFRESH lt_schedules_inx.
REFRESH conditions1.
REFRESH order_text.
lv_itemno = 10.
ENDAT.
ELSE.
REFRESH gt2_zprice.
CLEAR chbox.
ENDIF.
ENDLOOP.
WRITE: /01(179) sy-uline.
PERFORM headings.
WRITE: /01(179) sy-uline.
PERFORM displaydata.
ENDCASE.
11-07-2007 7:28 PM
Before the at new, remember to:
SORT gt4_zprice BY kunnr divi.
This will take care of both. Please do F1 on AT NEW.
Rob
Message was edited by:
Rob Burbank
11-07-2007 7:17 PM
Instead of this one in your loop:
AT NEW kunnr.
MOVE 'Y' TO lv_flg.
ENDAT.
Put
AT NEW DIVISION.
MOVE 'Y' TO lv_flg.
ENDAT.
Regards,
Naimesh Patel
11-07-2007 7:25 PM
Hi Naimesh,
Thank you for your reply. I need 2 conditions here if KUNNR is different, different SO and for the same Kunnr, if DIVISION is different then also new SO. Please help me.
Thanks,
Veni.
11-07-2007 7:28 PM
Before the at new, remember to:
SORT gt4_zprice BY kunnr divi.
This will take care of both. Please do F1 on AT NEW.
Rob
Message was edited by:
Rob Burbank
11-07-2007 7:41 PM
Hi Rob,
I added sort statement,
gt4_zprice[] = gt2_zprice[].
SORT gt4_zprice BY kunnr vtweg.
LOOP AT gt4_zprice INTO gs_zprice1.
IF gs_zprice1-crmemo IS INITIAL.
AT NEW kunnr. " vtweg.
MOVE 'Y' TO lv_flg.
ENDAT.
IF lv_flg EQ 'Y'.
PERFORM headerdata.
PERFORM texts.
CLEAR lv_flg.
ENDIF.
Should I say 'AT NEW kunnr' or 'vtweg'.
Thanks,
Veni.
11-07-2007 7:49 PM
It depends also on the structure of the table - which fields are at the beginning. Please check the help.
Rob
11-07-2007 7:49 PM
11-07-2007 10:07 PM
11-07-2007 10:09 PM
I am not able to give the points. There are no radio buttons.
-Veni.
11-07-2007 10:17 PM
Glad to help - the point system has been down for a day or so.
Rob