SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Create Sales Order using SD_SALESDOCUMENT_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Thu Jan 24, 2008 10:57 pm    Post subject: Create Sales Order using SD_SALESDOCUMENT_CREATE Reply with quote

Code:
* Variablen und Strukturen
DATA:  headerin  TYPE bapisdhd1,
       headerout TYPE bapisdhd,
       itemsin   TYPE TABLE OF bapisditm WITH HEADER LINE,
       partner   TYPE TABLE OF bapiparnr WITH HEADER LINE,
       schedin   TYPE TABLE OF bapischdl WITH HEADER LINE.

DATA: zsd_preisfindung TYPE zsd_preisfindung.


*Parameter für Selektionsbild, können von externen Aufruf gefüllt werden
PARAMETERS:  p_auart  TYPE  bapisdhd1-doc_type,
             p_vkorg  TYPE  bapisdhd1-sales_org,
             p_vtweg  TYPE  bapisdhd1-distr_chan,
             p_spart  TYPE  bapisdhd1-division,
             p_pdate  TYPE  bapisdhd1-price_date,

             p_prolle TYPE bapiparnr-partn_role,
             p_partn  TYPE bapiparnr-partn_numb,

             p_matnr  TYPE bapisditm-material,
             p_menge  TYPE bapisditm-target_qty,
             p_eidat  TYPE bapischdl-req_date.

START-OF-SELECTION.
* Füllen der Daten für Aufruf des Funktionsbausteins *********
* Kopfdaten füllen
  headerin-doc_type = p_auart.
  headerin-sales_org = p_vkorg.
  headerin-distr_chan = p_vtweg.
  headerin-division = p_spart.
  headerin-price_date = p_pdate.

*Partner füllen + Auftraggeber
  partner-partn_role = p_prolle.
  partner-partn_numb = p_partn.
  APPEND partner.

*Positionsdaten füllen
  itemsin-material = p_matnr.
  itemsin-target_qty = p_menge.
  APPEND itemsin.

*Einteilungen füllen
  schedin-req_date = p_eidat.
  schedin-req_qty = p_menge.
  APPEND schedin.


* Auftrag anlegen anhand, jedoch nur im Testlauf
  CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
       EXPORTING
*           SALESDOCUMENT           =
            sales_header_in        =  headerin
*           SALES_HEADER_INX        =
*           SENDER                  =
*           BINARY_RELATIONSHIPTYPE = ' '
*           INT_NUMBER_ASSIGNMENT   = ' '
*           BEHAVE_WHEN_ERROR       = ' '
*           LOGIC_SWITCH            = switch
*           BUSINESS_OBJECT         = ' '
            testrun                 = 'X'
*           CONVERT_PARVW_AUART     = ' '
*           STATUS_BUFFER_REFRESH   = ' '
      IMPORTING
*           SALESDOCUMENT_EX        =
            sales_header_out        = headerout
      TABLES
            return                  = zsd_preisfindung-bapiret2_t[]
            sales_items_in          = itemsin[]
*           SALES_ITEMS_INX         =
            sales_partners          = partner[]
            sales_schedules_in      = schedin[]
*           SALES_SCHEDULES_INX     =
*           SALES_CONDITIONS_IN     =
*           SALES_CFGS_REF          =
*           SALES_CFGS_INST         =
*           SALES_CFGS_PART_OF      =
*           SALES_CFGS_VALUE        =
*           SALES_CFGS_BLOB         =
*           SALES_CFGS_VK           =
*           SALES_CFGS_REFINST      =
*           SALES_CCARD             =
*           SALES_TEXT              =
*           SALES_KEYS              =
*           SALES_CONTRACT_IN       =
*           SALES_CONTRACT_INX      =
*           EXTENSIONIN             =
*           PARTNERADDRESSES        =
*           SALES_SCHED_CONF_IN     =
*           ITEMS_EX                =
*           SCHEDULE_EX             =
*           BUSINESS_EX             =
*           INCOMPLETE_LOG          =
*           EXTENSIONEX             =
*           CONDITIONS_EX           =
*           BATCH_CHARC             =
            .

* Preis, Währung und Stückpreis wegschreiben
  MOVE-CORRESPONDING headerout TO zsd_preisfindung.
  zsd_preisfindung-net_val_hd_st =
                             zsd_preisfindung-net_val_hd / p_menge.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 70
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Mon Dec 29, 2008 11:32 pm    Post subject: Reply with quote

Code:
DATA: order_header_in LIKE bapisdhd1.
DATA: order_items_in TYPE STANDARD TABLE OF bapisditm WITH HEADER LINE.
DATA: order_schedules_in
TYPE STANDARD TABLE OF bapischdl WITH HEADER LINE.
DATA: order_partners TYPE STANDARD TABLE OF bapiparnr WITH HEADER LINE.
DATA: return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
data: itemx like bapisditmx occurs 10 with header line.


order_header_in-doc_type = 'ZWV'.
order_header_in-sales_org = '1000'.
order_header_in-distr_chan = '10'.
order_header_in-division = '10'.
order_header_in-purch_date = sy-datum.
order_header_in-purch_no_c = 'BAPITEST'.

order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0001000005'.
APPEND order_partners.

order_partners-partn_role = 'ZS'.
order_partners-partn_numb = '1046'.
APPEND order_partners.

IF ORDER_HEADER_IN-DOC_TYPE = 'ZWV'.
ORDER_PARTNERS-ITM_NUMBER = '10'.
order_partners-partn_role = 'ZO'.
order_partners-partn_numb = '0001000005'.
APPEND order_partners.
ENDIF.


add next line with more than one item
order_items_in-itm_number = '000010'.

order_items_in-material = '000000000000111111'.
order_items_in-target_qty = '1.000'.
order_items_in-target_qu = 'ST'.
order_items_in-sales_unit = 'ST'.
APPEND order_items_in.
order_schedules_in-req_qty = '1.000'.
APPEND order_schedules_in.

*Add following lines with more than one line
itemx-itm_number = '000010'.
itemx-updateflag = 'I'.
itemx-material = 'X'.
itemx-target_qty = 'X'.
append itemx.



order_items_in-itm_number = '000020'.
order_items_in-material = '000000000000111111'.
order_items_in-target_qty = '1.000'.
order_items_in-target_qu = 'ST'.
order_items_in-sales_unit = 'ST'.
APPEND order_items_in.
order_schedules_in-req_qty = '1.000'.
APPEND order_schedules_in.

itemx-itm_number = '000020'.
itemx-updateflag = 'I'.
itemx-material = 'X'.
itemx-target_qty = 'X'.
append itemx.
*stop add more lines


REFRESH return.


BREAK-POINT.


CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
sales_header_in = order_header_in
TABLES
return = return
sales_items_in = order_items_in
sales_items_inx = itemx
sales_partners = order_partners
sales_schedules_in = order_schedules_in.

COMMIT WORK AND WAIT.
LOOP AT return.
WRITE: / return.
ENDLOOP.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.