cancel
Showing results for 
Search instead for 
Did you mean: 

Populating PO Date in Sales Order

ajoy_chakraborty
Participant
0 Kudos

Hi All,

I am trying to create a Sales Order w.r.t an Inquiry (PO -> Inquiry -> Sales Order).

I am using FM: SD_SALESDOCUMENT_CREATE to create an Inquiry. On checking the Inquiry in VA13, I am able to see both PO Number and PO Date.

After creation of Inquiry, I am using it as a reference to create SO using the same FM.

I am passing the following fields to the FM:

SALES_HEADER_IN:

REFDOCTYPE

DOC_TYPE

SALES_ORG = <VBAK-VKORG> - fetching details from VBAK by passing VBELN = Inquiry No. (REF_DOC)

DISTR_CHAN = <VBAK-VTWEG>

DIVISION = <VBAK-SPART>

REF_DOC = Inquiry No.

REFDOC_CAT = 'A'

PURCH_NO_C = <VBAK-BSTNK>

PURCH_DATE = <VBAK-BSTDK>

SALES_HEADER_INX:

Marked all the above corresponding fields as X

SALES_PARTNERS:

PARTN_ROLE = <Sold To Party>

PARTN_NUMB = <Sold to party number>

PARTN_ROLE = <Ship To Party>

PARTN_NUMB = <Ship to party number>

On executing, SO is getting created, but, I am getting following message:

The sales document is not yet complete: Edit data

On checking the SO, I found that PO Date is not getting populated (VA03 -> Edit -> Incompletion Log is also mentioning the same: MISSING DATA: PO Date)

Please advice.

Thanks & Regards,

Ajoy

Accepted Solutions (1)

Accepted Solutions (1)

kalyan_mokirala
Contributor
0 Kudos

Hi Ajoy,

One more very important thing once the new routine is added in the copy control routines in VTAA transaction and transport is moved to target system (quality and production), You have to execute the program RV80HGEN in SE38 else you will get dump message while performing the transactions. Please go through the below link whch explains about that.

http://scn.sap.com/thread/1793346

Hope this helps.

Answers (5)

Answers (5)

venkateswaran_k
Active Contributor
0 Kudos

Ajoy,

Can you please verify following items:

1.  In the Incompletion Log - what are all other fields it is mentioning?  Is it only the PO Date?

2.  Is that PO date is mandatory ?  ie  showing in Red colour?

3. Also please cross check is the Inquiry document is having the date ?

If so, 

For the testing purpose -- put statement as follows

If wa_order_items_in-purch_date is initial

   wa_order_items_in-purch_date =  sy-datum.

endif.

Regards,

Venkat

kalyan_mokirala
Contributor
0 Kudos

Hi Ajoy,

This is a simple development to be done in copy controls in VTAA header business data routine 101.Here it is mentioned that PO number and date must not be copied from source from source to target.

  FORM DATEN_KOPIEREN_101.

 

* Data which is not copied

 

LOCAL: VBKD-FKDAT.

LOCAL: VBKD-FPLNR.

LOCAL: VBKD-WKWAE.

LOCAL: VBKD-WKKUR.

LOCAL: VBKD-DELCO.

LOCAL: VBKD-BSTKD.

LOCAL: VBKD-ABSSC.

LOCAL: VBKD-BSTDK.

Commenting the code will allow you to copy the data from source to target.

Ask developer to create a new routine say 601 by copying 101 routine in VOFM (Data transfer routines) and assign the new routine in the copy controls header for inqury to quotation and quotation to order.

ajoy_chakraborty
Participant
0 Kudos

   **-Structure
  TYPES: BEGIN OF ty_vbap,
          vbeln TYPE vbeln_va,    "Sales Document
          posnr TYPE posnr_va,    "Sales Document Item
          matnr TYPE matnr,       "Material Number
          zmeng TYPE dzmeng,      "Target quantity
          werks TYPE werks_ext,   "Plant
          lgort TYPE lgort_d,     "Storage Location
         END OF ty_vbap.


**-Internal Table
  DATA: itab_vbap TYPE TABLE OF ty_vbap.

**-Work areas
  DATA: wa_vbap            TYPE ty_vbap,
        wa_order_items_in  TYPE bapisditm,
        wa_order_items_inx TYPE bapisditmx.

   **-Clear all the field values before using
    CLEAR: order_header_in-sales_org,
           order_header_in-distr_chan,
           order_header_in-division,
           order_header_in-refdoc_cat,
           order_header_in-req_date_h,
           order_header_in-purch_no_c,
           wa_order_items_in-purch_date.


**-Selecting all header related data from VBAK table
    SELECT SINGLE vbtyp       "SD document category
                  vkorg       "Sales Organization
                  vtweg       "Distribution Channel
                  spart       "Division
                  vdatu       "Requested delivery date
                  bstnk       "Customer purchase order number
                  bstdk       "Customer purchase order date
      FROM vbak               "Sales Document: Header Data
      INTO (order_header_in-refdoc_cat,
            order_header_in-sales_org,
            order_header_in-distr_chan,
            order_header_in-division,
            order_header_in-req_date_h,
            order_header_in-purch_no_c,
            wa_order_items_in-purch_date)
      WHERE vbeln EQ order_header_in-ref_doc.

*-Populating ORDER_HEADER_INX - Sales Order Check List
    order_header_inx-updateflag = ' '. "Update indicator
    order_header_inx-doc_type   = c_x. "Updated info in user data field
    order_header_inx-sales_org  = c_x. "Updated info in user data field
    order_header_inx-distr_chan = c_x. "Updated info in user data field
    order_header_inx-division   = c_x. "Updated info in user data field
    order_header_inx-req_date_h = c_x. "Updated info in user data field
    order_header_inx-purch_no_c = c_x. "Updated info in user data field
    order_header_inx-ref_doc    = c_x. "Updated info in user data field
    order_header_inx-refdoc_cat = c_x. "Updated info in user data field

*-Populating ORDER_ITEMS_IN - Item Data
*-For the corresponding document number, fetch all the Item details
*-from VBAP table and use them to populate item level details

**-Clearing all work areas before using
    CLEAR: wa_vbap,
           wa_order_items_in-itm_number,
           wa_order_items_in-material,
           wa_order_items_in-store_loc,
           wa_order_items_in-target_qty,
           wa_order_items_inx-itm_number,
           wa_order_items_inx-material,
           wa_order_items_inx-store_loc,
           wa_order_items_inx-target_qty,
           wa_order_items_inx-purch_date.

    REFRESH itab_vbap.

    SELECT vbeln    "Sales Document
           posnr    "Sales Document Item
           matnr    "Material Number
           zmeng    "Target quantity
           werks    "Plan
           lgort    "Storage Location
      FROM vbap     "Sales Document: Item Data
      INTO TABLE itab_vbap
      WHERE vbeln EQ order_header_in-ref_doc.

    LOOP AT itab_vbap INTO wa_vbap.
*-ITEM NUMBER
      wa_order_items_in-itm_number  = wa_vbap-posnr.
      wa_order_items_inx-itm_number = wa_vbap-posnr.
*-UPDATE FLAG
      wa_order_items_inx-updateflag = ' '.
*-MATERIAL
      IF NOT wa_vbap-matnr IS INITIAL.
        wa_order_items_in-material  = wa_vbap-matnr.
        wa_order_items_inx-material = c_x.
      ENDIF.
*-STORAGE LOCATION
      IF NOT wa_vbap-lgort IS INITIAL.
        wa_order_items_in-store_loc  = wa_vbap-lgort.
        wa_order_items_inx-store_loc = c_x.
      ENDIF.
*-TARGET QUANTITY
      IF NOT wa_vbap-zmeng IS INITIAL.
        wa_order_items_in-target_qty  = wa_vbap-zmeng.
        wa_order_items_inx-target_qty = c_x.
      ENDIF.

*-PO DATE
      IF NOT wa_order_items_in-purch_date IS INITIAL.
        wa_order_items_inx-purch_date = c_x.
      ENDIF.

*-Create entries in ORDER_ITEMS_IN table
      INSERT wa_order_items_in INTO TABLE order_items_in.
*-Create entries in ORDER_ITEMS_INX table
      INSERT wa_order_items_inx INTO TABLE order_items_inx.

**-Clearing all work areas before using
      CLEAR: wa_vbap,
             wa_order_items_in-itm_number,
             wa_order_items_in-material,
             wa_order_items_in-store_loc,
             wa_order_items_in-target_qty,
             wa_order_items_inx-itm_number,
             wa_order_items_inx-material,
             wa_order_items_inx-store_loc,
             wa_order_items_inx-target_qty,
             wa_order_items_inx-purch_date.
    ENDLOOP.

**-Calling BAPI for Sales Order creation
    CLEAR salesdocument.
    REFRESH return.


**-Calling function module for Sales Order creation
    CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
      EXPORTING
        sales_header_in  = order_header_in
        sales_header_inx = order_header_inx
      IMPORTING
        salesdocument_ex = salesdocument
      TABLES
        return           = return
        sales_items_in   = order_items_in
        sales_items_inx  = order_items_inx
        sales_partners   = order_partners.

   **-If sales doc is created successfully - call BAPI_TRANSACTION_COMMIT
  IF NOT salesdocument IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = c_x.
  ENDIF.

PLEASE NOTE: Ref. Doc Type, Document Type, Inquiry No. and Ship To/ Sold To party details will be passed by the calling system (will call using RFC)

venkateswaran_k
Active Contributor
0 Kudos

Hi

Try using - BAPI_SALESORDER_CREATEFROMDAT2.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

Former Member
0 Kudos

Hi,

please send 'X' to order_header_inx-updateflag

also in the query why are you sending value in items instead of header

SELECT SINGLE vbtyp       "SD document category

                  vkorg       "Sales Organization

                  vtweg       "Distribution Channel

                  spart       "Division

                  vdatu       "Requested delivery date

                  bstnk       "Customer purchase order number

                  bstdk       "Customer purchase order date

      FROM vbak               "Sales Document: Header Data

      INTO (order_header_in-refdoc_cat,

            order_header_in-sales_org,

            order_header_in-distr_chan,

            order_header_in-division,

            order_header_in-req_date_h,

            order_header_in-purch_no_c,

           wa_order_items_in-purch_date)

      WHERE vbeln EQ order_header_in-ref_doc.

you are sending PO number in header and PO date in item...

header has fields BAPISDHD1-PURCH_DATE and BAPISDHD1-PURCH_NO_C also same are in items

BAPISDITM-PURCH_NO_C

BAPISDITM-PURCH_DATE

check you requirement and do...

Regards

Tejas

Message was edited by: tejas patil

madhu_vadlamani
Active Contributor
0 Kudos

Hi,

can you try with indicator I.

t_order_header_in-purch_date = sy-datum.

t_order_header_in-doc_type = 'YMTA'.

t_order_header_in-req_date_h = '20100808'.

"t_order_header_in-po_method = 'EA'.

t_order_header_in-PRICE_DATE = '20100908'.

t_order_header_in-purch_no_c = '3456'.


Regards,

Madhu.

former_member186385
Active Contributor
0 Kudos

Hi,

In copy control VTAA  check what is the routine assigned for Business data

in order to copy the PO data from reference document to target document, you have to use 101 -Business data header

regards,

santosh

madhu_vadlamani
Active Contributor
0 Kudos

Hi Ajoy,

Please give more information.

Regards,

Madhu.

Former Member
0 Kudos

Hi,

can you please paste whole Header data filling code here..

so that we can figure it out where exactly the problem is...

have you sent value to field updateflag...

regards

Tejas