Skip to Content
0
Former Member
Oct 06, 2009 at 08:12 AM

After creating new sales order through BAPI, it is not showing in VA03

364 Views

Hi Experts

I am developing one program to create sales order using FM BAPI_SALESORDER_CREATEFROMDAT2. In output screen it is showing that the new sales order number created with new sales order number. But whenever I want to display the newly created sales order via VA03 it shows an error message SD document 10007547 is not in the database or has been archived but in program output it shows that 10007547 is created. This is in DEV server. Document numbers are generated by the system sequencially, but it is not reflected in database.

I am also attaching my code below.

REPORT z_bapi_salesorder.

DATA : gt_header LIKE bapisdhd1,

gt_item TYPE TABLE OF bapisditm,

gt_itemx TYPE TABLE OF bapisditmx,

gt_partner TYPE TABLE OF bapiparnr,

gt_return TYPE TABLE OF bapiret2.

DATA : gs_item LIKE LINE OF gt_item,

gs_itemx LIKE LINE OF gt_itemx,

gs_partner LIKE LINE OF gt_partner,

gs_return LIKE LINE OF gt_return.

DATA : v_vbeln TYPE vbeln_va.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 2(30) ord_type FOR FIELD p_auart.

PARAMETERS : p_auart TYPE auart OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : p_vkorg TYPE vkorg OBLIGATORY,

p_vtweg TYPE vtweg OBLIGATORY,

p_spart TYPE vbak-spart OBLIGATORY,

p_sold TYPE kunnr OBLIGATORY,

p_ship TYPE kunnr OBLIGATORY,

p_matnr TYPE matnr OBLIGATORY,

p_menge TYPE kwmeng OBLIGATORY,

p_plant TYPE werks_d OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b1.

INITIALIZATION.

ord_type = 'Order Type'.

START-OF-SELECTION.

*Header information data.

gt_header-doc_type = p_auart.

gt_header-sales_org = p_vkorg.

gt_header-distr_chan = p_vtweg.

gt_header-division = p_spart.

*Partner information data.

gs_partner-partn_role = 'AG'.

gs_partner-partn_numb = p_sold.

APPEND gs_partner TO gt_partner.

CLEAR gs_partner.

gs_partner-partn_role = 'WE'.

gs_partner-partn_numb = p_ship.

APPEND gs_partner TO gt_partner.

CLEAR gs_partner.

*Item data

gs_item-itm_number = '000010'.

gs_itemx-itm_number = 'X'.

gs_item-material = p_matnr.

gs_itemx-material = 'X'.

gs_item-plant = p_plant.

gs_itemx-plant = 'X'.

gs_item-target_qty = p_menge.

gs_itemx-target_qty = 0.

APPEND gs_item TO gt_item.

APPEND gs_itemx TO gt_itemx.

CLEAR : gs_item, gs_itemx.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = gt_header

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

salesdocument = v_vbeln

TABLES

return = gt_return

order_items_in = gt_item

order_items_inx = gt_itemx

order_partners = gt_partner

  • ORDER_SCHEDULES_IN =

  • ORDER_SCHEDULES_INX =

  • ORDER_CONDITIONS_IN =

  • ORDER_CONDITIONS_INX =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

  • ORDER_CCARD =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • EXTENSIONIN =

  • PARTNERADDRESSES =

.

IF v_vbeln <> space.

COMMIT WORK.

WRITE :/ 'Document', v_vbeln ,'created'.

CLEAR : v_vbeln, gt_header.

REFRESH : gt_partner, gt_item, gt_itemx.

ELSE.

WRITE :/ 'Error in creating document'.

ENDIF.

Please give the possible solutions for this. What is reason for that update termination.