Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sales Order creation question

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.

Tags:
replied

You must use

'AT NEW vtweg'

regards,

Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question