Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi all,

I am using BAPI_SALESORDER_CREATEFROMDAT2 to create a standard sales order..I am filling the texts table..I am able to get the header texts in the table parameter ORDER_TEXT..

The problem is when i go to the standard transaction VA03 only the first line

of the text is shown..Lines written after an enter are not updated in texts of VA03..

Can u plz help me out with the problem and how to proceed..

E.g : I am enetering texts like -


Text 1

Text 2

Text 3

But in VA03 it is shown only as -


Text 1

Plz help me solve the problem..

Helpful answers will be rewarded..

Thanx

Arun

1 ACCEPTED SOLUTION

Former Member

Hi

see the doc of the fun module

FU BAPI_SALESORDER_CREATEFROMDAT2

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN structure) and partner data (via the ORDER_PARTNERS table) as input parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item numbers manually, by filling in the relevant fields, or the system does it, according to the settings for Customizing, by leaving the relevant fields blank.

If you have configurable items, you must enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one hand, data for card identification, on the other, data for a transaction which has taken place in an external system.

Once you have created the sales order successfully, you will receive the document number (SALESDOCUMENT field). Any errors that may occur will be announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the system creates the sales area from the sold-to party or ship-to party, who has been entered in the partner table. If a clear sales area cannot be created, you will receive a system message, and the sales order will not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the relevant application must leave the commit, in order that can be carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains general information on the BAPIs in SD.

Parameters

SALESDOCUMENTIN

ORDER_HEADER_IN

ORDER_HEADER_INX

SENDER

BINARY_RELATIONSHIPTYPE

INT_NUMBER_ASSIGNMENT

BEHAVE_WHEN_ERROR

LOGIC_SWITCH

TESTRUN

CONVERT

SALESDOCUMENT

RETURN

ORDER_ITEMS_IN

ORDER_ITEMS_INX

ORDER_PARTNERS

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

Exceptions

Sample code:

************SALES ORDER INPUT CREATION.

PARAMETERS: p_auart TYPE auart OBLIGATORY.

PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.

PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.

PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

PARAMETERS: p_sold TYPE kunnr OBLIGATORY.

PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

*ITEM

PARAMETERS: p_matnr TYPE matnr OBLIGATORY.

PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.

PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.

  • DATA DECLARATIONS.

DATA: v_vbeln LIKE vbak-vbeln.

DATA: header LIKE bapisdhead1.

DATA: headerx LIKE bapisdhead1x.

DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.

DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.

DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.

DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx

WITH HEADER LINE.

DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl

WITH HEADER LINE.

  • HEADER DATA

header-doc_type = p_auart.

headerx-doc_type = 'X'.

header-sales_org = p_vkorg.

headerx-sales_org = 'X'.

header-distr_chan = p_vtweg.

headerx-distr_chan = 'X'.

header-division = p_spart.

headerx-division = 'X'.

headerx-updateflag = 'I'.

  • PARTNER DATA

partner-partn_role = 'AG'.

partner-partn_numb = p_sold.

APPEND partner.

partner-partn_role = 'WE'.

partner-partn_numb = p_ship.

APPEND partner.

  • ITEM DATA

itemx-updateflag = 'I'.

item-itm_number = '000010'.

itemx-itm_number = 'X'.

item-material = p_matnr.

itemx-material = 'X'.

item-plant = p_plant.

itemx-plant = 'X'.

item-target_qty = p_menge.

itemx-target_qty = 'X'.

item-target_qu = 'EA'.

itemx-target_qu = 'X'.

item-item_categ = p_itcat.

itemx-item_categ = 'X'.

APPEND item.

APPEND itemx.

  • Fill schedule lines

lt_schedules_in-itm_number = '000010'.

lt_schedules_in-sched_line = '0001'.

lt_schedules_in-req_qty = p_menge.

APPEND lt_schedules_in.

  • Fill schedule line flags

lt_schedules_inx-itm_number = '000010'.

lt_schedules_inx-sched_line = '0001'.

lt_schedules_inx-updateflag = 'X'.

lt_schedules_inx-req_qty = 'X'.

APPEND lt_schedules_inx.

  • Call the BAPI

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

EXPORTING

sales_header_in = header

sales_header_inx = headerx

IMPORTING

salesdocument_ex = v_vbeln

TABLES

return = return

sales_items_in = item

sales_items_inx = itemx

sales_schedules_in = lt_schedules_in

sales_schedules_inx = lt_schedules_inx

sales_partners = partner.

  • Check the return table.

LOOP AT return WHERE type = 'E' OR type = 'A'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'Error in creating document'.

ELSE.

COMMIT WORK AND WAIT.

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

ENDIF.

<b>Reward points if useful</b>

Regards

Ashu

6 REPLIES 6

Former Member
0 Kudos

please try this example program.

REPORT ZBAPI_SALESORDER_CREATE LINE-SIZE 132 MESSAGE-ID ZMMBAPI .

----


  • Internal table definition *

----


****<<<<<Communication Fields: Sales and Distribution Document Header>>>>>>>>

DATA: GT_ORDER_HEADER_IN LIKE BAPISDHD1,

*******<<<Checkbox Fields for Sales and Distribution Document Header>>>>>>>>>

GT_ORDER_HEADER_INX LIKE BAPISDHD1X,

*****<<<<<Return Parameter>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

GT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE, " Return Messages

*********<<<Communication Fields: Sales and Distribution Document Item<>>>>>

GT_ORDER_ITEMS_IN LIKE BAPISDITM OCCURS 0 WITH HEADER LINE, " Item Data

*********<<<Communication Fields: Sales and Distribution Document Item>>>>>>>

GT_ORDER_ITEMS_INX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE, "Item Data Checkbox

*********<<<Communication Fields: Sales and Distribution Document Item>>>>>>>

GT_SALESDOCUMENT LIKE BAPIVBELN-VBELN , "Number of Generated Document

*********<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>

GT_ORDER_PARTNERS LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE, "Document Partner

********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>

GT_ORDER_SCHEDULES_IN LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE, "Schedule Line Data

****<<<<<<<<Checkbox List for Maintaining Sales Document Schedule Line>>>>>>>>

GT_ORDER_SCHEDULES_INX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE, " Checkbox Schedule Line Data

*******Communication Fields for Maintaining Conditions in the Order

GT_ORDER_CONDITIONS_IN LIKE BAPICOND OCCURS 0 WITH HEADER LINE,

******Communication Fields for Maintaining Conditions in the Order

GT_ORDER_CONDITIONS_INX LIKE BAPICONDX OCCURS 0 WITH HEADER LINE.

----


  • Data definition *

----


DATA: BEGIN OF GT_FT_SALES OCCURS 0,

DOC_TYPE(4) , "Sales Document Type

SALES_ORG(4) , "Sales Organization

DISTR_CHAN(2) , "Distribution Channel

DIVISION(2) , "DIVISION(2)

SALES_DIST(6) , "Sales district

INCOTERMS1(3) , "Incoterms (part 1)

INCOTERMS2(28) , "Incoterms (part 2)

PMNTTRMS(4) , "Terms of payment key

PRICE_DATE(8) , "Date for pricing and exchange rate

PURCH_NO_C(35) , "Customer purchase order number

PURCH_NO_S(35) , "Ship-to Party's Purchase Order Number

EXCHG_RATE(8) , "Directly quoted exchange rate for pricing and statistics

CURRENCY(5) , "SD document currency

MATERIAL(18), "MATERIAL

TARGET_QTY(13) , "Target quantity in sales units

ITEM_CATEG(4) , "Sales document item category

MATL_GROUP(8) , "Material Group

PURCH_NO_C1(35), "Customer purchase order number

SALES_DIST1(6) , "Sales district

INCOTERMS11(3) , "Incoterms (part 1)

INCOTERMS21(28), "Incoterms (part 2)

PMNTTRMS1(4) , "Terms of payment key

EXCHG_RATE1(8) , "Directly quoted exchange rate for pricing and statistics

PRICE_DATE1(8) , "Date for pricing and exchange rate

TRG_QTY_NO(5) , "Factor for converting sales units to base units (target qty)

DIVISION1(2) , "DIVISION1

SALQTYNUM(5) , "Numerator (factor) for conversion of sales quantity into SKU

GROSS_WGHT(3) , "Gross Weight of the Item

NET_WEIGHT(15) , "Net Weight of the Item

UNTOF_WGHT(3) ,"Weight Unit

PARTN_ROLE(2) ,"Partner function

PARTN_NUMB(10) ,"Customer Number 1

********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>

ITM_NUMBER(6) ,"Item number of the SD document

REQ_QTY(8) , "Schedule line date

DLV_DATE(8) , "Schedule line date

MS_DATE(8) , "Material availability date

LOAD_DATE(8) , "Loading time (local time with reference to a shipping point)

GI_DATE(8), "Time of goods issue (local DATE, with reference to a plant)

TP_DATE(8) , "Transportation planning -time (local w/ref. to shipping pnt)

ITM_NUMBER2(6) , "Condition item number

END OF GT_FT_SALES,

MSG(240) TYPE C, " Return Message

E_REC(8) TYPE C, " Error Records Counter

REC_NO(8) TYPE C, " Records Number Indicator

S_REC(8) TYPE C, " Successful Records Counter

T_REC(8) TYPE C. " Total Records Counter

    • selection block for EXCEL UPLOAD FILE>>>>>>>>>>>>>>>>>>>>>>>>

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

PARAMETERS FILE TYPE IBIPPARMS-PATH OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

*<<<<AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .>>>>>>>>>>>>

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = FILE.

**<<<<<<<<<<<<<<<<<START-OF-SELECTION.>>>>>>>>>>>>>>>>>>>>>>>>>>>

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD' "#EC *

EXPORTING

FILENAME = FILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = GT_FT_SALES

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

NO_AUTHORITY = 10

OTHERS = 11.

IF SY-SUBRC <> 0 .

MESSAGE E000.

ENDIF.

SKIP 3.

FORMAT COLOR COL_HEADING INVERSE ON.

WRITE 40 TEXT-001.

FORMAT COLOR COL_HEADING INVERSE OFF.

SKIP 1.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

WRITE 😕 TEXT-002, 13 SY-MANDT , 104 TEXT-003, 111 SY-UNAME,

/ TEXT-004, 13 SY-DATUM , 104 TEXT-005, 111 SY-UZEIT.

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

SKIP 3.

LOOP AT GT_FT_SALES.

PERFORM SLALE_UPLOAD_DATA.

ENDLOOP.

T_REC = E_REC + S_REC.

SKIP 3.

FORMAT COLOR COL_TOTAL INVERSE ON.

WRITE: /38 TEXT-007, T_REC.

FORMAT COLOR COL_TOTAL INVERSE OFF.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

WRITE: /38 TEXT-008, E_REC.

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

FORMAT COLOR COL_TOTAL INVERSE ON.

WRITE: /38 TEXT-009, S_REC.

FORMAT COLOR COL_TOTAL INVERSE OFF.

&----


*& Form SLALE_UPLOAD_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM SLALE_UPLOAD_DATA .

*******<<<<<<<<<<Communication Fields: Sales and Distribution Document Header>>>>>>

GT_ORDER_HEADER_IN-DOC_TYPE = 'TA'.

GT_ORDER_HEADER_IN-SALES_ORG = GT_FT_SALES-SALES_ORG . "'0001'

GT_ORDER_HEADER_IN-DISTR_CHAN = GT_FT_SALES-DISTR_CHAN. "'01'

GT_ORDER_HEADER_IN-DIVISION = GT_FT_SALES-DIVISION. " '01'

GT_ORDER_HEADER_IN-SALES_DIST = GT_FT_SALES-SALES_DIST ."'000001'

GT_ORDER_HEADER_IN-INCOTERMS1 = GT_FT_SALES-INCOTERMS1. "'CFR'

GT_ORDER_HEADER_IN-INCOTERMS2 = GT_FT_SALES-INCOTERMS2 . "'HAMBURG'

GT_ORDER_HEADER_IN-PMNTTRMS = GT_FT_SALES-PMNTTRMS . "'0001'

GT_ORDER_HEADER_IN-PRICE_DATE = GT_FT_SALES-PRICE_DATE ."'20060818'

GT_ORDER_HEADER_IN-PURCH_NO_C = '32'.

GT_ORDER_HEADER_IN-PURCH_NO_S = '32'.

GT_ORDER_HEADER_IN-EXCHG_RATE = GT_FT_SALES-EXCHG_RATE ."'1.00000'

GT_ORDER_HEADER_IN-CURRENCY = GT_FT_SALES-CURRENCY . " 'EUR'

********<<<Checkbox Fields for Sales and Distribution Document Header>>>>>>>>>

GT_ORDER_HEADER_INX-DOC_TYPE = 'X'.

GT_ORDER_HEADER_INX-SALES_ORG = 'X'.

GT_ORDER_HEADER_INX-DISTR_CHAN = 'X'.

GT_ORDER_HEADER_INX-DIVISION = 'X'.

GT_ORDER_HEADER_INX-SALES_DIST = 'X'.

GT_ORDER_HEADER_INX-INCOTERMS1 = 'X'.

GT_ORDER_HEADER_INX-INCOTERMS2 = 'X'.

GT_ORDER_HEADER_INX-PMNTTRMS = 'X'.

GT_ORDER_HEADER_INX-PRICE_DATE = 'X'.

GT_ORDER_HEADER_INX-PURCH_NO_C = 'X'.

GT_ORDER_HEADER_INX-PURCH_NO_S = 'X'.

GT_ORDER_HEADER_INX-EXCHG_RATE = 'X'.

GT_ORDER_HEADER_INX-CURRENCY = 'X'.

*****<<<<<<Communication Fields: Sales and Distribution Document Item>>>

GT_ORDER_ITEMS_IN-ITM_NUMBER = '000010'.

GT_ORDER_ITEMS_IN-MATERIAL = GT_FT_SALES-MATERIAL .

GT_ORDER_ITEMS_IN-PO_ITM_NO = '32'.

GT_ORDER_ITEMS_IN-CUST_MAT22 = 'AGNI-IV'.

GT_ORDER_ITEMS_IN-BILL_DATE = '20060808'.

GT_ORDER_ITEMS_IN-PLANT = '0001'.

*GT_ORDER_ITEMS_IN-STORE_LOC = '0001'.

GT_ORDER_ITEMS_IN-TARGET_QTY = GT_FT_SALES-TARGET_QTY . "'1000'

GT_ORDER_ITEMS_IN-ITEM_CATEG = GT_FT_SALES-ITEM_CATEG . "'TAN'

GT_ORDER_ITEMS_IN-MATL_GROUP = GT_FT_SALES-MATL_GROUP . "'01'

GT_ORDER_ITEMS_IN-PURCH_NO_C = GT_FT_SALES-PURCH_NO_C . "'32'

GT_ORDER_ITEMS_IN-SALES_DIST = GT_FT_SALES-SALES_DIST . "'000001'

GT_ORDER_ITEMS_IN-INCOTERMS1 = GT_FT_SALES-INCOTERMS1 . "'CFR'

GT_ORDER_ITEMS_IN-INCOTERMS2 = GT_FT_SALES-INCOTERMS2 . "'HAMBURG'

GT_ORDER_ITEMS_IN-PMNTTRMS = GT_FT_SALES-PMNTTRMS . "'0001'.

GT_ORDER_ITEMS_IN-EXCHG_RATE = GT_FT_SALES-EXCHG_RATE . "'1.00000'

GT_ORDER_ITEMS_IN-PRICE_DATE = GT_FT_SALES-PRICE_DATE . "'20060808'

*GT_ORDER_ITEMS_IN-SALES_UNIT = 'DZ'.

GT_ORDER_ITEMS_IN-TRG_QTY_NO = GT_FT_SALES-TRG_QTY_NO . "'23'

GT_ORDER_ITEMS_IN-DIVISION = GT_FT_SALES-DIVISION . "'01'

GT_ORDER_ITEMS_IN-SALQTYNUM = GT_FT_SALES-SALQTYNUM . "'32'

GT_ORDER_ITEMS_IN-GROSS_WGHT = GT_FT_SALES-GROSS_WGHT. " ' 25272000'

GT_ORDER_ITEMS_IN-NET_WEIGHT = GT_FT_SALES-NET_WEIGHT. "'24464000'

GT_ORDER_ITEMS_IN-UNTOF_WGHT = GT_FT_SALES-UNTOF_WGHT . " 'KG'

*GT_ORDER_ITEMS_IN-CURRENCY = 'EUR'.

APPEND GT_ORDER_ITEMS_IN.

****<<<<<<Communication Fields: Sales and Distribution Document Item>>>

GT_ORDER_ITEMS_INX-ITM_NUMBER = '000010'.

GT_ORDER_ITEMS_INX-MATERIAL = 'X'.

*GT_ORDER_ITEMS_INX-PO_ITM_NO = 'X'.

GT_ORDER_ITEMS_INX-CUST_MAT22 = 'X'.

GT_ORDER_ITEMS_INX-BILL_DATE = 'X'.

GT_ORDER_ITEMS_INX-PLANT = 'X'.

*GT_ORDER_ITEMS_INX-STORE_LOC = 'X'.

GT_ORDER_ITEMS_INX-TARGET_QTY = 'X'.

GT_ORDER_ITEMS_INX-ITEM_CATEG = 'X'.

GT_ORDER_ITEMS_INX-MATL_GROUP = 'X'.

GT_ORDER_ITEMS_INX-PURCH_NO_C = 'X'.

GT_ORDER_ITEMS_INX-SALES_DIST = 'X'.

GT_ORDER_ITEMS_INX-INCOTERMS1 = 'X'.

GT_ORDER_ITEMS_INX-INCOTERMS2 = 'X'.

GT_ORDER_ITEMS_INX-PMNTTRMS = 'X'.

GT_ORDER_ITEMS_INX-EXCHG_RATE = 'X'.

GT_ORDER_ITEMS_INX-PRICE_DATE = 'X'.

*GT_ORDER_ITEMS_INX-SALES_UNIT = 'X'.

GT_ORDER_ITEMS_INX-TRG_QTY_NO = 'X'.

GT_ORDER_ITEMS_INX-DIVISION = 'X'.

GT_ORDER_ITEMS_INX-SALQTYNUM = 'X'.

GT_ORDER_ITEMS_INX-GROSS_WGHT = 'X'.

GT_ORDER_ITEMS_INX-NET_WEIGHT = 'X'.

GT_ORDER_ITEMS_INX-UNTOF_WGHT = 'X'.

*GT_ORDER_ITEMS_IN-CURRENCY = 'x'.

APPEND GT_ORDER_ITEMS_INX.

*****<<<<<<Communications Fields: SD Document Partner: WWW

GT_ORDER_PARTNERS-PARTN_ROLE = 'WE'.

GT_ORDER_PARTNERS-PARTN_NUMB = '0000000057'.

***GT_ORDER_PARTNERS-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER . " '000010'.

APPEND GT_ORDER_PARTNERS.

*********<<<<Communications Fields: SD Document Partner: WWW>>>>>>>>>>>>>>>>>>

GT_ORDER_SCHEDULES_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER." '000010'

GT_ORDER_SCHEDULES_IN-REQ_QTY = GT_FT_SALES-REQ_QTY . "'234'

GT_ORDER_SCHEDULES_IN-DLV_DATE = GT_FT_SALES-DLV_DATE ." '20060824'.

GT_ORDER_SCHEDULES_IN-MS_DATE = GT_FT_SALES-MS_DATE . "'20060808'

GT_ORDER_SCHEDULES_IN-LOAD_DATE = GT_FT_SALES-LOAD_DATE. " '20060822'

GT_ORDER_SCHEDULES_IN-GI_DATE = GT_FT_SALES-GI_DATE . " '20060823'

GT_ORDER_SCHEDULES_IN-TP_DATE = GT_FT_SALES-TP_DATE . "'20060821'

APPEND gt_ORDER_SCHEDULES_IN.

*********<<<<Communications Fields: SD Document Partner: WWW FLAG>>>>>>>>>>>>>>>>>>

GT_ORDER_SCHEDULES_INX-ITM_NUMBER = '000010'.

GT_ORDER_SCHEDULES_INX-REQ_QTY = 'X'.

GT_ORDER_SCHEDULES_INX-DLV_DATE = 'X'.

GT_ORDER_SCHEDULES_INX-MS_DATE = 'X'.

GT_ORDER_SCHEDULES_INX-LOAD_DATE = 'X'.

GT_ORDER_SCHEDULES_INX-GI_DATE = 'X'.

GT_ORDER_SCHEDULES_INX-DLV_DATE = 'X'.

APPEND gt_ORDER_SCHEDULES_INX.

********Communication Fields for Maintaining Conditions in the Order

GT_ORDER_CONDITIONS_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER ." '000010'

APPEND GT_ORDER_CONDITIONS_IN.

***Communication Fields for Maintaining Conditions in the Order

GT_ORDER_CONDITIONS_INX-ITM_NUMBER = '000010'.

APPEND GT_ORDER_CONDITIONS_INX.

*

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

ORDER_HEADER_IN = GT_ORDER_HEADER_IN

ORDER_HEADER_INX = GT_ORDER_HEADER_INX

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = GT_SALESDOCUMENT

TABLES

RETURN = GT_RETURN

ORDER_ITEMS_IN = GT_ORDER_ITEMS_IN

ORDER_ITEMS_INX = GT_ORDER_ITEMS_INX

ORDER_PARTNERS = GT_ORDER_PARTNERS

ORDER_SCHEDULES_IN = GT_ORDER_SCHEDULES_IN

ORDER_SCHEDULES_INX = GT_ORDER_SCHEDULES_INX

ORDER_CONDITIONS_IN = GT_ORDER_CONDITIONS_IN

ORDER_CONDITIONS_INX = GT_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 GT_RETURN-TYPE EQ 'E' .

E_REC = E_REC + 1.

READ TABLE GT_RETURN WITH KEY ID = 'V1'.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

REC_NO = E_REC + S_REC.

CONCATENATE TEXT-006 REC_NO ':'

GT_RETURN-MESSAGE INTO MSG SEPARATED BY SPACE .

CONDENSE MSG.

WRITE: / MSG.

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

ELSEIF GT_RETURN-TYPE EQ 'S'.

S_REC = S_REC + 1.

FORMAT COLOR COL_POSITIVE INVERSE ON.

MSG = GT_RETURN-MESSAGE.

CONDENSE MSG.

WRITE: / MSG .

FORMAT COLOR COL_POSITIVE INVERSE OFF.

PERFORM COMMIT_MM.

ENDIF.

CLEAR: GT_RETURN[], MSG.

ENDFORM. " SLALE_UPLOAD_DATA

&----


*& Form COMMIT_MM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM COMMIT_MM .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = GT_RETURN.

clear: GT_ORDER_ITEMS_IN[],GT_ORDER_CONDITIONS_IN[].

ENDFORM. " COMMIT_MM

************************************************************************

REPORT ZBAPI_SALESORDER_CHANGE LINE-SIZE 132 MESSAGE-ID ZMMBAPI .

----


  • Internal table definition *

----


*****<<<< BAPI Sales Order>>>>>>>>>>>>>>>>>>>>>>>

DATA: GT_SALESDOCUMENT LIKE BAPIVBELN-VBELN,

******<<<<Communication Fields: SD Order Header>>>

GT_ORDER_HEADER_IN LIKE BAPISDH1,

******<<<<<Checkbox List: SD Order Header>>>>>>>>>

GT_ORDER_HEADER_INX LIKE BAPISDH1X,

*****<<<Return Parameter>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

GT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,

*******<<<<<<<Communication Fields: Sales and Distribution Document Item>>

GT_ORDER_ITEM_IN LIKE BAPISDITM OCCURS 0 WITH HEADER LINE,

*******<<<<<<<Communication Fields: Sales and Distribution Document Item>>

GT_ORDER_ITEM_INX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE,

*******<<<<<<<<Communication Fields for Maintaining Conditions in the Order

GT_CONDITIONS_IN LIKE BAPICOND OCCURS 0 WITH HEADER LINE,

*******<<<<<<<<Communication Fields for Maintaining Conditions in the Order

GT_CONDITIONS_INX LIKE BAPICONDX OCCURS 0 WITH HEADER LINE.

----


  • FLAT FLIE Internal table definition *

----


DATA: BEGIN OF GT_FT_SALES OCCURS 0,

SALESDOCUMENT(10), "SALESDOCUMENT

SALES_ORG(4) , "Sales Organization

DISTR_CHAN(2), "Sales Organization

DIVISION(2) , " DIVISION

PURCH_NO_C(35) , "Customer purchase order number

SALES_DIST(6) , "Sales district

INCOTERMS1(3) , "INCOTERMS1

PMNTTRMS(4) , "Terms of payment key

ITM_NUMBER(6) , "Sales Document Item

PO_ITM_NO(6) , "Item Number of the Underlying Purchase Order

MATERIAL(18), "Material Number

END OF GT_FT_SALES,

MSG(240) TYPE C, " Return Message

E_REC(8) TYPE C, " Error Records Counter

REC_NO(8) TYPE C, " Records Number Indicator

S_REC(8) TYPE C, " Successful Records Counter

T_REC(8) TYPE C, " Total Records Counter

ERR_ORDER(10) TYPE C. " Order Number Indicator

    • selection block for EXCEL UPLOAD FILE>>>>>>>>>>>>>>>>>>>>>>>>

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.

PARAMETERS FILE TYPE IBIPPARMS-PATH OBLIGATORY.

SELECTION-SCREEN END OF BLOCK B1.

*<<<<AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .>>>>>>>>>>>>

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = FILE.

**<<<<<<<<<<<<<<<<<START-OF-SELECTION.>>>>>>>>>>>>>>>>>>>>>>>>>>>

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD' "#EC *

EXPORTING

FILENAME = FILE

FILETYPE = 'DAT'

TABLES

DATA_TAB = GT_FT_SALES

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

NO_AUTHORITY = 10

OTHERS = 11.

IF SY-SUBRC <> 0 .

MESSAGE E000.

ENDIF.

SKIP 3.

FORMAT COLOR COL_HEADING INVERSE ON.

WRITE 40 TEXT-001.

FORMAT COLOR COL_HEADING INVERSE OFF.

SKIP 1.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

WRITE 😕 TEXT-002, 13 SY-MANDT , 104 TEXT-003, 111 SY-UNAME,

/ TEXT-004, 13 SY-DATUM , 104 TEXT-005, 111 SY-UZEIT.

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

SKIP 3.

LOOP AT GT_FT_SALES.

PERFORM UPLOAD_FILE.

ENDLOOP.

T_REC = E_REC + S_REC.

SKIP 3.

FORMAT COLOR COL_TOTAL INVERSE ON.

WRITE: /38 TEXT-007, T_REC.

FORMAT COLOR COL_TOTAL INVERSE OFF.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

WRITE: /38 TEXT-008, E_REC.

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

FORMAT COLOR COL_TOTAL INVERSE ON.

WRITE: /38 TEXT-009, S_REC.

FORMAT COLOR COL_TOTAL INVERSE OFF.

&----


*& Form UPLOAD_FILE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM UPLOAD_FILE .

********<<<< BAPI Sales Order>>>>>>>>>>>>>>>>>>>>>>>

GT_SALESDOCUMENT = GT_FT_SALES-SALESDOCUMENT . " '0000000233' "Order Number

******<<<<Communication Fields: SD Order Header>>>

GT_ORDER_HEADER_IN-SALES_ORG = GT_FT_SALES-SALES_ORG . "'0001' "Sales Organization

GT_ORDER_HEADER_IN-DISTR_CHAN = GT_FT_SALES-DISTR_CHAN . "Distribution Channel

GT_ORDER_HEADER_IN-DIVISION = GT_FT_SALES-DIVISION . "Division

GT_ORDER_HEADER_IN-PURCH_NO_C = GT_FT_SALES-PURCH_NO_C . "Customer purchase order number

GT_ORDER_HEADER_IN-SALES_DIST = GT_FT_SALES-SALES_DIST . " Sales district

GT_ORDER_HEADER_IN-INCOTERMS1 = GT_FT_SALES-INCOTERMS1 . "Incoterms (part 1)

GT_ORDER_HEADER_IN-PMNTTRMS = GT_FT_SALES-PMNTTRMS . "Terms of payment key

******<<<<Communication Fields: SD Order Header FLAG>>>

GT_ORDER_HEADER_INX-UPDATEFLAG = 'U'.

GT_ORDER_HEADER_INX-SALES_ORG = 'X'. "Sales Organization

GT_ORDER_HEADER_INX-DISTR_CHAN = 'X'. "Distribution Channel

GT_ORDER_HEADER_INX-DIVISION = 'X'. "Division

GT_ORDER_HEADER_INX-PURCH_NO_C = 'X' ."Customer purchase order number

GT_ORDER_HEADER_INX-SALES_DIST = 'X'. " Sales district

GT_ORDER_HEADER_INX-INCOTERMS1 = 'X'."Incoterms (part 1)

GT_ORDER_HEADER_INX-PMNTTRMS = 'X'. "Terms of payment key

*******<<<<<<<Communication Fields: Sales and Distribution Document Item>>

GT_ORDER_ITEM_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER . "'000010' "Sales Document Item

GT_ORDER_ITEM_IN-PO_ITM_NO = GT_FT_SALES-PO_ITM_NO . "'PO-129' "Item Number of the Underlying Purchase Order

GT_ORDER_ITEM_IN-MATERIAL = GT_FT_SALES-MATERIAL . "'M-24' "Material Number

APPEND GT_ORDER_ITEM_IN.

*******<<<<<<<Communication Fields: Sales and Distribution Document Item>>

GT_ORDER_ITEM_INX-UPDATEFLAG = 'U'.

GT_ORDER_ITEM_INX-ITM_NUMBER = '000010'. "Sales Document Item

GT_ORDER_ITEM_INX-PO_ITM_NO = 'X'. "Item Number of the Underlying Purchase Order

GT_ORDER_ITEM_INX-MATERIAL = 'X'. "Material Number

APPEND GT_ORDER_ITEM_INX.

*******<<<<<<<<Communication Fields for Maintaining Conditions in the Order>>>>

GT_CONDITIONS_IN-ITM_NUMBER = GT_FT_SALES-ITM_NUMBER . "'000010' "Condition item number

APPEND GT_CONDITIONS_IN.

*******<<<<<<<<Communication Fields for Maintaining Conditions in the Order FLAG>>>

GT_CONDITIONS_INX-ITM_NUMBER = '000010' ."Condition item number

APPEND GT_CONDITIONS_INX.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = GT_SALESDOCUMENT

ORDER_HEADER_IN = GT_ORDER_HEADER_IN

ORDER_HEADER_INX = GT_ORDER_HEADER_INX

TABLES

RETURN = GT_RETURN

ORDER_ITEM_IN = GT_ORDER_ITEM_IN

ORDER_ITEM_INX = GT_ORDER_ITEM_INX

CONDITIONS_IN = GT_CONDITIONS_IN

CONDITIONS_INX = GT_CONDITIONS_INX.

IF GT_RETURN-TYPE EQ 'E'.

ERR_ORDER = GT_RETURN-MESSAGE_V1.

READ TABLE GT_RETURN WITH KEY ID = 'V1'.

E_REC = E_REC + 1.

CONCATENATE TEXT-006 ERR_ORDER ':' GT_RETURN-MESSAGE INTO MSG SEPARATED BY SPACE .

CONDENSE MSG.

FORMAT COLOR COL_NEGATIVE INVERSE ON.

WRITE / MSG .

FORMAT COLOR COL_NEGATIVE INVERSE OFF.

ELSEIF GT_RETURN-TYPE EQ 'S'.

S_REC = S_REC + 1.

FORMAT COLOR COL_POSITIVE INVERSE ON.

WRITE / GT_RETURN-MESSAGE .

FORMAT COLOR COL_POSITIVE INVERSE OFF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = GT_RETURN.

ENDIF.

ENDFORM. " UPLOAD_FILE

Former Member
0 Kudos

Hi..

There is no logic to fetch the header text in ur program and that was my querry..

Thanks..

Former Member

Hi

see the doc of the fun module

FU BAPI_SALESORDER_CREATEFROMDAT2

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN structure) and partner data (via the ORDER_PARTNERS table) as input parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item numbers manually, by filling in the relevant fields, or the system does it, according to the settings for Customizing, by leaving the relevant fields blank.

If you have configurable items, you must enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one hand, data for card identification, on the other, data for a transaction which has taken place in an external system.

Once you have created the sales order successfully, you will receive the document number (SALESDOCUMENT field). Any errors that may occur will be announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the system creates the sales area from the sold-to party or ship-to party, who has been entered in the partner table. If a clear sales area cannot be created, you will receive a system message, and the sales order will not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the relevant application must leave the commit, in order that can be carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains general information on the BAPIs in SD.

Parameters

SALESDOCUMENTIN

ORDER_HEADER_IN

ORDER_HEADER_INX

SENDER

BINARY_RELATIONSHIPTYPE

INT_NUMBER_ASSIGNMENT

BEHAVE_WHEN_ERROR

LOGIC_SWITCH

TESTRUN

CONVERT

SALESDOCUMENT

RETURN

ORDER_ITEMS_IN

ORDER_ITEMS_INX

ORDER_PARTNERS

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

Exceptions

Sample code:

************SALES ORDER INPUT CREATION.

PARAMETERS: p_auart TYPE auart OBLIGATORY.

PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.

PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.

PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

PARAMETERS: p_sold TYPE kunnr OBLIGATORY.

PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

*ITEM

PARAMETERS: p_matnr TYPE matnr OBLIGATORY.

PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.

PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.

  • DATA DECLARATIONS.

DATA: v_vbeln LIKE vbak-vbeln.

DATA: header LIKE bapisdhead1.

DATA: headerx LIKE bapisdhead1x.

DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.

DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.

DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.

DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx

WITH HEADER LINE.

DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl

WITH HEADER LINE.

  • HEADER DATA

header-doc_type = p_auart.

headerx-doc_type = 'X'.

header-sales_org = p_vkorg.

headerx-sales_org = 'X'.

header-distr_chan = p_vtweg.

headerx-distr_chan = 'X'.

header-division = p_spart.

headerx-division = 'X'.

headerx-updateflag = 'I'.

  • PARTNER DATA

partner-partn_role = 'AG'.

partner-partn_numb = p_sold.

APPEND partner.

partner-partn_role = 'WE'.

partner-partn_numb = p_ship.

APPEND partner.

  • ITEM DATA

itemx-updateflag = 'I'.

item-itm_number = '000010'.

itemx-itm_number = 'X'.

item-material = p_matnr.

itemx-material = 'X'.

item-plant = p_plant.

itemx-plant = 'X'.

item-target_qty = p_menge.

itemx-target_qty = 'X'.

item-target_qu = 'EA'.

itemx-target_qu = 'X'.

item-item_categ = p_itcat.

itemx-item_categ = 'X'.

APPEND item.

APPEND itemx.

  • Fill schedule lines

lt_schedules_in-itm_number = '000010'.

lt_schedules_in-sched_line = '0001'.

lt_schedules_in-req_qty = p_menge.

APPEND lt_schedules_in.

  • Fill schedule line flags

lt_schedules_inx-itm_number = '000010'.

lt_schedules_inx-sched_line = '0001'.

lt_schedules_inx-updateflag = 'X'.

lt_schedules_inx-req_qty = 'X'.

APPEND lt_schedules_inx.

  • Call the BAPI

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

EXPORTING

sales_header_in = header

sales_header_inx = headerx

IMPORTING

salesdocument_ex = v_vbeln

TABLES

return = return

sales_items_in = item

sales_items_inx = itemx

sales_schedules_in = lt_schedules_in

sales_schedules_inx = lt_schedules_inx

sales_partners = partner.

  • Check the return table.

LOOP AT return WHERE type = 'E' OR type = 'A'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'Error in creating document'.

ELSE.

COMMIT WORK AND WAIT.

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

ENDIF.

<b>Reward points if useful</b>

Regards

Ashu

Former Member
0 Kudos

For appearing text on different line you have devide total text into 132 character strings and append different record to table bapi ORDER_TEXT table.

Regards,

Amit R.

0 Kudos

Hi Amit,

I am trying the same but the problem still persists..

Only the first line of the text is getting updated..

Plz clarify with the help of a code if u can..

Thanx

Arun

Former Member
0 Kudos

thanks