Sales order report with Net value (NETWR) and Tax amount (MWSBP)
Hi all,
I would like to know if somebody know if exist a report of sales order where it can see the Net value and the Tax amount per sales order.
Regards,
Mariano.
You can read those details directly in the table VBAP.
There are fields for COST, Subtotal1, to subtotal 6, which carries values for netvalue, discounts etc. Depending on the system pricing procedure sub total set-up you can read the tax from one of the sub-total fields.
You can develop an ABAP query by joining tables VBAK and VBAP, to get the required outputs if needed. Or you can download the VBAP values into an Excel application, where user can manipulate the details.
Regards,
Similar Messages
-
Sales order report with order attachments
Hi All
I am writing a program for a 2 part report that gives a list of sales orders with attachment flags and a list of invoices that do not have the output processed due to the presence of attachment flag.
Firstly i need help regarding few queries in the process of writing this program.
1. How can i distinguish between a sales order with attachement and one without an attachment.
2. What is the related field for attachment in sales header/sales item table(s) or any other sales related table which will contain information of the attachment in the sales order.
3. If I have an attachment in sales order, will it have an effect in the output being processed for the invoice for that order.
Thanks in Advance
--MikeHello Erik,
is there a sales order report with the complete line-item pricing
breakdown. For example, In VA05 I'm only able to get the Net
Price and Net Value as an output. I would also like to view the
breakdown of the conditions (e.g. disounts, tax, etc.)
Is there another report in SAP that will show this? Or a backend
table I can pull this information from to create a query?
The best way to handle your requirement is to create a Custom report using the standard table for Sales Order i.e. VBAK and you can pick up the Document Condition Number. You can pass this number to table KONV and pull up all the values for the active contion type which was responsible for Sales Order price calculation. Please reach out to a ABAPer to develop this sort of a custom report.
Just FYI, if you want to check out all the value for a specific condition type, then you can use the standard report i.e. V/LD.
Please update your post after carrying out this exercise.
Regards,
Sarthak -
Sales Order Report with Pricing Breakdown
HI, is there a sales order report with the complete line-item pricing breakdown. For example, In VA05 I'm only able to get the Net Price and Net Value as an output. I would also like to view the breakdown of the conditions (e.g. disounts, tax, etc.)
Is there another report in SAP that will show this? Or a backend table I can pull this information from to create a query?
Thanks, ErikHello Erik,
is there a sales order report with the complete line-item pricing
breakdown. For example, In VA05 I'm only able to get the Net
Price and Net Value as an output. I would also like to view the
breakdown of the conditions (e.g. disounts, tax, etc.)
Is there another report in SAP that will show this? Or a backend
table I can pull this information from to create a query?
The best way to handle your requirement is to create a Custom report using the standard table for Sales Order i.e. VBAK and you can pick up the Document Condition Number. You can pass this number to table KONV and pull up all the values for the active contion type which was responsible for Sales Order price calculation. Please reach out to a ABAPer to develop this sort of a custom report.
Just FYI, if you want to check out all the value for a specific condition type, then you can use the standard report i.e. V/LD.
Please update your post after carrying out this exercise.
Regards,
Sarthak -
Open sales order report with billing date.
Hi,
I want to know if there's an available report for open sales order with billing date field.
Thank you.Hi,
If your case is "Order-related" Billing,you can use the T.Code "VF04" for this purpose.
One more way is to go for a custom report.
Make a copy of code of the T.Code "VA05n"(Program Name is "SD_SALES_ORDERS_VIEW").
Change the code as per your requirement to display the field "Billing Date" in the report.
Check with your ABAPer if you wish to go for a custom report.
Regards,
Krishna. -
Sales order BOm with Both Header material and line item delivery
Hi,
We have one requirment we have two products Products A and B, when we are salling only product B we have some amount for that e.g 1000 rupees but when we are salling product A along with this product B is free of cost so as in SO it is not accepting the 0 amount thats why while making SO for product A we reduce 1 rupee from product A and that 1 rupee we are adding for the Free item B but now every time we have to add both material in SO
So is there any way when we make the So for product A automatically product B should come in So and price of product A is from VK11 but price of B should always be 1 and while creating delivery with VL01 both material we want to delivery and do the PGi in the same way we required billing doucment for both the material and in case we are salling only product B price should be from VK11.
How to customize the system for above requirement.
regards,
zafarHi Zafar,
Free goods determination is not supported in SAP for structured material like BOM.
For your requirement, you need not have to create a BOM materiall, simple free goods determination is suitable.
You can create an Exclusive free goods condition record where material A will be the main item and material B will be the sub item (free of charge).
So create the Condition record for Exclusive free goods in VBN1.
When you will create the Sales order for material A, system will take the above materials "A" as Main item (Item category TAN) and "B" Sub-item (Item category TANN) respectively.
When you will create DELIVERY , both the items will be delivered and you can do PGI.
As and when required you can also sell material B separately.
Regards
Pradyumna -
Do we have standard report to show sale order stock with amount?
Do we have standard report to show sale order stock with amount?
I try to use MB5B and MBBS but they don't show value.
MB5B show only qty
MBBS no any report.
Please kindly help.
Thank you very much.Okay Thank you very much for your suggestion.
I think I have to create a new ZProgram. T_T -
Throw Information message for sale order created with value less that 5$
Hi all,
I am basically an abaper, I have got a requirement in SD. The requirement is any sales order created with value less that 5$, should be prompted with an error message saying the minimum order value should be more than 5$. Could any one help me on this.
Thanks in advance,
shivuserexit_save_document_prepare,main program - sapmv45a, issue an error message if your document value is less than 5$ (VBAK-NETWR) but check if your order has any non-rejected item, I would not issue this message if all items are rejected:
loop at xvbap where updkz ne 'D' and abgru = ' '.
exit.
endloop.
if sy-subrc = 0. "-you have at least one non-rejected, non-deleted item.
NOTE: sapmv45a works NOT only for orders, so please check document types in your logic which are relevant to your messge only (VBAK-VBTYP and/or VBAK-AUART). -
Hi,
I have a code to display Sales order report. But i need to generate Sales order Line item wise Report. Can anyone help me to modify this code to suit my criteria?
DATA: IT_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.
DATA: IT_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE.
PARAMETERS: SORG LIKE VBAK-VKORG,
CCODE LIKE VBAK-BUKRS_VF.
SELECT * FROM VBAK INTO TABLE IT_VBAK UP TO 100 ROWS
WHERE
VKORG = SORG AND
BUKRS_VF = CCODE.
SELECT * FROM VBAP INTO TABLE IT_VBAP UP TO 100 ROWS
FOR ALL ENTRIES IN IT_VBAK
WHERE
VBELN = IT_VBAK-VBELN.
LOOP AT IT_VBAP.
WRITE: / IT_VBAP-VBELN, IT_VBAP-ERNAM, IT_VBAP-POSNR.
ENDLOOP.
Thanks in advance..
Any help will be greatly appritiatedHi
Hope it will help you..
Reward if help.
REPORT ZVRDOC0 no standard page heading
line-size 300
line-count 50(5).
TABLES : vbak, "Sales Document Header Level
vbap, "Sales Document Header Level
kna1. "General Data in customer Master
*INTERNAL TABLE T_VBAP
DATA : Begin of t_vbap occurs 0,
vbeln like vbap-vbeln,
matnr like vbap-matnr,
posnr like vbap-posnr,
arktx like vbap-arktx,
kwmeng like vbap-kwmeng,
cmkua like vbap-cmkua,
end of t_vbap.
*INTERNAL TABLE T_TAB.
DATA : Begin of t_tab occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
audat like vbak-audat,
netwr like vbak-netwr,
vkorg like vbak-vkorg,
name1 like kna1-name1,
land1 like kna1-land1,
end of t_tab.
*INTERNAL TABLE T_FINAL.
DATA : Begin of t_final occurs 0,
vbeln like vbap-vbeln,
kunnr like vbak-kunnr,
matnr like vbap-matnr,
posnr like vbap-posnr,
arktx like vbap-arktx,
kwmeng like vbap-kwmeng,
cmkua like vbap-cmkua,
audat like vbak-audat,
netwr like vbak-netwr,
vkorg like vbak-vkorg,
name1 like kna1-name1,
land1 like kna1-land1,
end of t_final.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-bO3.
parameters : P_kunnr like vbak-kunnr.
select-options : S_vbeln for vbak-vbeln,
S_audat for vbak-audat.
SELECTION-SCREEN END OF BLOCK B1.
start-of-selection.
select vbeln matnr posnr arktx kwmeng cmkua from vbap
into corresponding fields of table t_vbap where vbeln in S_vbeln .
IF sy-subrc EQ 0.
select vbakkunnr vbakvbeln vbakaudat vbaknetwr vbak~vkorg
kna1name1 kna1land1 into table t_Tab from
vbak join kna1 on kna1kunnr = vbakkunnr
FOR ALL ENTRIES IN t_vbap
where vbak~vbeln = t_vbap-Vbeln and
vbak~kunnr = p_kunnr and
vbak~audat in S_audat .
ENDIF.
*end-of-selection.
loop at t_vbap.
read table t_tab with key vbeln = t_vbap-vbeln.
move :
t_vbap-vbeln to t_final-vbeln,
t_vbap-matnr to t_final-matnr,
t_vbap-posnr to t_final-posnr,
t_vbap-arktx to t_final-arktx,
t_vbap-kwmeng to t_final-kwmeng,
t_vbap-cmkua to t_final-cmkua,
t_tab-kunnr to t_final-kunnr,
t_tab-audat to t_final-audat,
t_tab-netwr to t_final-netwr,
t_tab-vkorg to t_final-vkorg,
t_tab-name1 to t_final-name1,
t_tab-land1 to t_final-land1.
append t_final.
clear t_Final.
endloop.
sort t_Final by vbeln Kunnr matnr posnr .
loop at t_final.
at new vbeln.
write : /1 SY-VLINE, 2 t_final-vbeln color 5 inverse.
ULINE /1(250).
endat.
write : /1 SY-VLINE, 2 t_final-vbeln color 5 inverse,
20 SY-VLINE, 21 t_final-posnr color 5 inverse,
40 SY-VLINE, 41 t_final-matnr color 5 inverse,
60 SY-VLINE, 61 t_final-arktx color 4 inverse,
80 SY-VLINE, 81 t_final-kwmeng color 4 inverse,
100 SY-VLINE, 101 t_final-cmkua color 4 inverse,
120 SY-VLINE, 121 t_final-kunnr color 3 inverse,
140 SY-VLINE, 141 t_final-audat color 3 inverse,
160 SY-VLINE, 161 t_final-netwr color 2 inverse,
180 SY-VLINE, 181 t_final-vkorg color 2 inverse,
210 SY-VLINE, 211 t_final-name1 color 1 inverse,
230 SY-VLINE, 231 t_final-land1 color 1 inverse,
250 SY-VLINE.
at end of vbeln.
sum.
ULINE /1(250).
write: /60 SY-VLINE, 'Total' ,
81 t_final-kwmeng color 4 inverse ,100 SY-VLINE,
101 t_final-cmkua color 4 inverse,120 SY-VLINE.
ULINE /1(250).
endat.
at last.
SKIP 2.
sum.
ULINE /1(250).
write: /1 SY-VLINE, 60 SY-VLINE, 'Grand Total' ,
81 t_final-kwmeng color 4 inverse , 100 SY-VLINE ,
101 t_final-cmkua color 4 inverse,120 SY-VLINE.
ULINE /1(250).
endat.
endloop.
TOP-OF-PAGE.
ULINE /50(24).
WRITE : /50 SY-VLINE , 52 'SALES ORDER DETAILS' COLOR 5,
73 SY-VLINE.
ULINE /50(24).
ULINE .
WRITE: /10 'CURRENT DATE :', 25 SY-DATUM COLOR 1 INVERSE,
100 'CURRENT TIME :', 115 SY-UZEIT color 5 INVERSE.
WRITE: /10 'USERNAME :', 25 SY-UNAME COLOR 1 INVERSE,
100 'PAGE NO :', 113 SY-PAGNO COLOR 5 INVERSE.
WRITE: /10 'LOGON CLIENT :', 25 SY-MANDT COLOR 1 INVERSE,
100 'COLON N0 :', 114 SY-COLNO COLOR 5 INVERSE.
WRITE: /10 'CURRENT REPROT:', 25 SY-REPID COLOR 1 INVERSE,
100 'LANGUAGE :', 116 SY-LANGU COLOR 5 INVERSE.
ULINE.
ULINE /1(250).
write : /1 SY-VLINE, 2 'SALES DOC NO' color 6 inverse,
20 SY-VLINE, 21 'SALES DOC ITEM' color 6 inverse,
40 SY-VLINE,41 'MATERIAL NO' color 6 inverse,
60 SY-VLINE, 61 'SHORT SALES TEXT' color 6 inverse,
80 SY-VLINE, 81 'CUMM ORDER SALES' color 6 inverse,
100 SY-VLINE, 101 'CREDIT DATA' color 6 inverse,
120 SY-VLINE, 121 'CUSTOMER NO' color 6 inverse,
140 SY-VLINE, 141 'DOC DATE' color 6 inverse,
160 SY-VLINE, 161 'NET VALUE SALES' color 6 inverse,
180 SY-VLINE, 181 'SALES ORG' color 6 inverse,
210 SY-VLINE, 211 'CUSTOMER NAME' color 6 inverse,
230 SY-VLINE, 231 'CUSTOMER CONTY' color 6 inverse,
250 SY-VLINE.
ULINE /1(250).
END-OF-PAGE.
ULINE.
WRITE: /45 ' THIS IS END OF PAGE FOR SALES DOCUMENT DETAILS'
COLOR 6 . -
Credit Block released Sales order report
Hi Experts,
My client is given few sales orders (around 4)no and requesting us, to prepare the credit block released sales orders report (include released person user ID).
*.No change logs is existing for all sales order and deliveries.
For above requirement I am using CDHDR table data but I am not getting credit block released sales order report.
Below fields I am using in CDHDR Table.
Change doc.Object (objectclas) : VERKBELEG
Document No (CHANGENR): Sales order no XXXXXXX
Transaction no (TCODE) : VKM1,VKM2,VKM3
Date(UDATE) : 25.09.2011 to 09.11.2011
Experts, Can you please help me out for this.
Thanking you!!!!
Regards,
Vijaykumar Kola
*.I'm already aware of this is a new development.Try this, simple report... Here we check the new value of credit status field VBUK-CMGST and if it is 'D' we know that someone used VKM* transaction to release the document. Also you need to format the sales order number with leading zeros so it occupies all 10 digits and pass it to CDHDR-OBJECTID field (and not CHANGENR field). In the below code I am using select option for sales order number, so I know it will be formatted with leading zeros and so select on CDHDR will be successful.
*& Report ZTV_TEST
REPORT ztv_test.
TABLES: vbak, cdhdr.
SELECT-OPTIONS: s_saldoc FOR vbak-vbeln OBLIGATORY,
s_udate FOR cdhdr-udate.
RANGES: r_objid FOR cdhdr-objectclas.
DATA: ls_cdhdr TYPE cdhdr,
ls_cdpos TYPE cdpos.
IF NOT s_saldoc IS INITIAL.
LOOP AT s_saldoc.
MOVE-CORRESPONDING s_saldoc TO r_objid.
CONDENSE: r_objid-high, r_objid-low.
APPEND r_objid.
ENDLOOP.
ENDIF.
CHECK NOT r_objid[] IS INITIAL.
SELECT *
INTO ls_cdhdr
FROM cdhdr
WHERE objectclas = 'VERKBELEG' AND
objectid IN r_objid AND
udate IN s_udate AND
tcode LIKE 'VKM%'.
SELECT SINGLE *
INTO ls_cdpos
FROM cdpos
WHERE objectclas = ls_cdhdr-objectclas AND
objectid = ls_cdhdr-objectid AND
changenr = ls_cdhdr-changenr AND
tabname = 'VBUK' AND
fname = 'CMGST' AND
value_new = 'D'.
IF sy-subrc = 0.
WRITE:/ ls_cdhdr-objectid(10), ls_cdhdr-username,
ls_cdhdr-udate, ls_cdhdr-utime.
ENDIF.
ENDSELECT. -
BAPI SALES ORDER & Copy with reference
Hello,
I'm creating sales order copied with reference to an invoice. My problem is that the data item is empty. When I create the sales order manually and use the option 'Create with reference' and choose an invoice, the sales order is created with all data item. I don't know how I can get to copy the data item from the invoice in the new sales order. The code that I'm using is the following:
DATA: order_header_in LIKE bapisdhd1,
order_partners LIKE bapiparnr OCCURS 0 WITH HEADER LINE,
order_text LIKE bapisdtext OCCURS 0 WITH HEADER LINE,
order_header_inx LIKE bapisdhd1x,
order_item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,
order_schedules_in LIKE bapischdl OCCURS 0 WITH HEADER LINE,
order_conditions_in LIKE bapicond OCCURS 0 WITH HEADER LINE,
extensionin LIKE bapiparex OCCURS 0 WITH HEADER LINE,
partneraddresses LIKE bapiaddr1 OCCURS 0 WITH HEADER LINE,
order_cfgs_ref like BAPICUCFG occurs 0 with header line.
DATA: salesdocument LIKE bapivbeln-vbeln.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
order_header_in-doc_type = 'ZA09'.
order_header_in-sales_org = '1700'.
order_header_in-distr_chan = '01'.
order_header_in-division = '01'.
order_header_in-BILL_DATE = '20060701'.
order_header_in-ref_doc = '0900000019'.
order_header_in-refdoc_cat = 'M'.
*order_header_in-REF_DOC_L_LONG = '0900000019'.
order_header_in-purch_no_c ='prueba'.
*order_header_in-ord_reason = '003'.
*order_header_in-pmnttrms = '0002'.
*order_header_in-sales_off = '2800'.
order_header_in-ref_doc_l = 'FACTURA ES'.
*order_header_in-fix_val_dy = '20060701'.
*order_header_in-currency = 'USD'.
*order_header_in-exchg_rate = '1.2'.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0000000001'.
order_partners-langu = 'EN'.
order_partners-name = 'El corte aleman'.
order_partners-country = 'ES'.
APPEND order_partners.
order_partners-partn_role = 'RE'.
order_partners-partn_numb = 'ARR000'.
order_partners-addr_link = '0000030044'.
APPEND order_partners.
CALL FUNCTION 'ADDR_GET_COMPLETE_ALL_TYPES'
EXPORTING
addrnumber = order_partners-addr_link
PERSNUMBER =
address_object_type = '1'
IV_CURRENT_COMM_DATA = 'X'
IMPORTING
ADDR1_COMPLETE =
ADDR2_COMPLETE =
ADDR3_COMPLETE =
ADDR1_COMPLETE_BAPI = partneraddresses
ADDR2_COMPLETE_BAPI =
ADDR3_COMPLETE_BAPI =
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
PERSON_NOT_EXIST = 3
INTERNAL_ERROR = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data: vl_texto(40) value 'NUEVOOOOO'.
partneraddresses-name = vl_texto. clear vl_texto.
partneraddresses-name_2 = vl_texto.
partneraddresses-name_3 = vl_texto.
partneraddresses-name_4 = vl_texto.
partneraddresses-langu = 'E'.
APPEND partneraddresses.
DATA: vl_cantidad LIKE bapisditm-target_qty.
vl_cantidad = 1.
order_item_in-itm_number = 10.
order_item_in-material = 'HONORARIOS'.
order_item_in-ref_doc = '0900000019'.
order_item_in-ref_doc_it = 10.
order_item_in-ref_doc_ca = 'M'.
APPEND order_item_in.
order_schedules_in-itm_number = 10.
order_schedules_in-req_qty = vl_cantidad.
APPEND order_schedules_in.
order_text-text_id = 'Z001'.
order_text-ITM_NUMBER = ''.
order_text-langu = 'EN'.
order_text-text_line = 'Hola, CARACOLAcola'.
APPEND order_text.
order_text-text_id = 'Z001'.
order_text-langu = 'EN'.
order_text-text_line = 'Adios caracol'.
APPEND order_text.
order_text-itm_number = '000010'.
order_text-text_id = '0001'.
order_text-langu = 'EN'.
order_text-text_line = 'Hola, POSICIÓN'.
APPEND order_text.
extensionin-structure = 'BAPE_VBAK'.
extensionin-valuepart1 = ' BCL 7'.
APPEND extensionin.
order_cfgs_ref-posex = '10'.
order_cfgs_ref-config_id = '10'.
order_cfgs_ref-root_id = '00000001'.
append order_cfgs_ref.
CALL FUNCTION 'ZBAPI_SALESORDER_CREATEFROMDT2'
EXPORTING
SALESDOCUMENTIN = salesdocument
order_header_in = order_header_in
ORDER_HEADER_INX = order_header_inx
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
salesdocument = salesdocument
TABLES
return = return
order_items_in = order_item_in
ORDER_ITEMS_INX =
order_partners = order_partners
order_schedules_in = order_schedules_in
ORDER_SCHEDULES_INX =
order_conditions_in = order_conditions_in
ORDER_CONDITIONS_INX =
ORDER_CFGS_REF = 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_text
ORDER_KEYS =
extensionin = extensionin
partneraddresses = partneraddresses
PERFORM report TABLES return.
*DATA: salesdocument LIKE bapivbeln-vbeln.
*DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*refresh return.
*CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'
EXPORTING
salesdocument = '0400000191'
documenttype = 'ZA04'
TESTRUN = ' '
IMPORTING
SALESDOCUMENT_EX = salesdocument
TABLES
RETURN = return
*PERFORM report TABLES return.
*write: / salesdocument.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
*& Form report
text
-->P_MENSAJE text
FORM report TABLES p_mensaje STRUCTURE bapiret2.
DATA: vl_mensaje TYPE string.
LOOP AT return.
CLEAR vl_mensaje.
MESSAGE ID return-id
TYPE return-type
NUMBER return-number
INTO vl_mensaje
WITH return-message_v1
return-message_v2
return-message_v3
return-message_v4.
WRITE: / vl_mensaje.
ENDLOOP.
ENDFORM. " reportHi Manuel,
There are some function modules which is there to copy the order details. I am not sure about the function module name. But you can search in SE37. But bapi for creating the sales order does not have the functionality of copying the data from one document to another document.
You can try using this function module.
BAPI_SALESDOCUMENT_COPY
Data will be copied based on the copy control routines that is set between the two document types.
Thanks,
Arun -
BAPI Sales order create with reference
Hi
I need to use BAPI to create sales order with reference to Quantity Contract. The line item material quantity would be less than or equal to quantity contract quantity.
Sales order needs to be created with new quantity.
Quantity contract quantity change needs to be maintained.
Document flow needs to be maintained.
Is any one aware if this is possible using BAPI_SALESORDER_CREATEFROMDAT2. If yes, how?
Any insights would be highly appreciated.Hi Maninder,
The BAPI does not allow the Pricing Conditions to be sourced from the Contract. I debugged the BAPI and it uses a piece of code (don't recall which subroutine though) from SAPMV45A which is relevant for dialog processing where it reads from the VBAP and *VBAP structures. Well this structure is only populated when you are using the Front End transaction (VA41, VA42, etc). Because this structure is empty, pricing conditions do not flow across.
Here is a little prototype program I whipped up to test my method of creating a Sales order and then changing the Sales Order:
REPORT ypat_salesorder_create LINE-SIZE 256.
* This program will create a ZOC Sales Order with Reference to Contract
* 20000720 / 10. This will be done via BAPI. There are 2 BAPi calls,
* BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE. We need to
* perform 2 BAPI calls as the BAPI to create the Sales Order does not
* bring across the Pricing Conditions properly. To get around this we
* create the Order with reference to the Contract, then we get the
* related Pricing Conditions from the COntract and then update the newly
* created Order.
* Constants
CONSTANTS: c_contract LIKE vbak-vbeln VALUE '0020000720',
c_item LIKE vbap-posnr VALUE '000010'.
* Structures
* Structure to hold BAPI Header
DATA: st_bapisdhd1 LIKE bapisdhd1.
* Internal Tables
* Sales Order Create BAPI Return Messages
DATA: tbl_return TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
* Sales Order BAPI Line Item
DATA: tbl_bapisditm TYPE STANDARD TABLE OF bapisditm
WITH HEADER LINE.
* Sales Order BAPI Line Item
DATA: tbl_bapisditmx TYPE STANDARD TABLE OF bapisditmx
WITH HEADER LINE.
* Sales Order BAPI Pricing Conditions
DATA: tbl_bapicond TYPE STANDARD TABLE OF bapicond
WITH HEADER LINE.
* Sales Order BAPI Partner Functions
DATA: tbl_bapiparnr TYPE STANDARD TABLE OF bapiparnr
WITH HEADER LINE.
* Sales Order BAPI Schedule Lines
DATA: tbl_bapischdl TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
* Sales Order BAPI Schedule Lines
DATA: tbl_bapischdlx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
* Sales Order BAPI Pricing Conditions
DATA: tbl_bapicondx TYPE STANDARD TABLE OF bapicondx
WITH HEADER LINE.
* Customer Enhancement for VBAK, VBAP, VBEP
DATA: tbl_bapiparex TYPE STANDARD TABLE OF bapiparex
WITH HEADER LINE.
* Table to hold BAPI Detail Conditions
DATA: tbl_bapisdcond TYPE STANDARD TABLE OF bapisdcond
WITH HEADER LINE.
* Table to hold Return Messages from Sales Order Change BAPI
DATA: tbl_return_chg TYPE STANDARD TABLE OF bapiret2
WITH HEADER LINE.
* Variables
DATA: g_vbeln_created LIKE vbak-vbeln,
g_valid_contract TYPE c,
g_cont_price_date TYPE d.
* Start of Selection
START-OF-SELECTION.
PERFORM validate_contract.
PERFORM create_sales_ord.
PERFORM update_sales_ord.
* End of Selection
END-OF-SELECTION.
PERFORM write_output_report.
* Subroutines
*& Form create_sales_ord
* Create the Sales Order
FORM create_sales_ord .
PERFORM populate_bapi_tables.
PERFORM call_create_sales_ord_bapi.
ENDFORM. " create_sales_ord
*& Form populate_bapi_tables
* Fill up the BAPI Tables
FORM populate_bapi_tables .
PERFORM populate_bapi_header.
PERFORM build_bapi_partners.
PERFORM build_bapi_items.
PERFORM build_bapi_sched_lines.
ENDFORM. " populate_bapi_tables
*& Form populate_bapi_header
* Build BAPI Header Details
FORM populate_bapi_header .
CLEAR st_bapisdhd1.
st_bapisdhd1-doc_type = 'ZOC'. "Order type
st_bapisdhd1-sales_org = '026'. "Sales Org
st_bapisdhd1-distr_chan = '00'. "Dist Channel
st_bapisdhd1-division = '00'. "Division
st_bapisdhd1-purch_no_c = 'Cust Po No'. "Cust PO No
st_bapisdhd1-name = 'Orderer'. "Name of Orderer
st_bapisdhd1-ord_reason = ''. "Order Reason
st_bapisdhd1-sales_off = '3001'. "Sales Office
st_bapisdhd1-sales_grp = '301'. "Market Area
IF g_valid_contract = 'X'.
st_bapisdhd1-price_date = g_cont_price_date.
ENDIF.
ENDFORM. " populate_bapi_header
*& Form build_bapi_partners
* Build BAPI Partner Functions
FORM build_bapi_partners .
CLEAR tbl_bapiparnr.
tbl_bapiparnr-partn_role = 'AG'.
tbl_bapiparnr-partn_numb = '0000100750'.
APPEND tbl_bapiparnr.
CLEAR tbl_bapiparnr.
tbl_bapiparnr-partn_role = 'WE'.
tbl_bapiparnr-partn_numb = '0000504472'.
APPEND tbl_bapiparnr.
ENDFORM. " build_bapi_partners
*& Form build_bapi_items
* Build The BAPI Line Items
FORM build_bapi_items .
DATA: l_matnr LIKE mara-matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '10000072'
IMPORTING
output = l_matnr.
CLEAR tbl_bapisditm.
tbl_bapisditm-itm_number = c_item.
IF g_valid_contract = 'X'.
tbl_bapisditm-ref_doc = c_contract.
tbl_bapisditm-ref_doc_it = c_item.
tbl_bapisditm-ref_doc_ca = 'G'. "Contract
ENDIF.
tbl_bapisditm-material = l_matnr.
tbl_bapisditm-plant = '3012'.
tbl_bapisditm-target_qty = '5.000'.
tbl_bapisditm-target_qu = 'M3'.
tbl_bapisditm-item_categ = 'ZZOC'.
tbl_bapisditm-sales_dist = '301'.
tbl_bapisditm-dlv_prio = '02'.
tbl_bapisditm-prc_group5 = '080'.
tbl_bapisditm-cust_mat35 = 'kdmat'.
tbl_bapisditm-route = 'TESYS'.
tbl_bapisditm-usage_ind = 'CIV'.
APPEND tbl_bapisditm.
CLEAR tbl_bapisditmx.
tbl_bapisditmx-itm_number = c_item.
tbl_bapisditmx-ref_doc = 'X'.
tbl_bapisditmx-ref_doc_it = 'X'.
tbl_bapisditmx-ref_doc_ca = 'X'.
tbl_bapisditmx-material = 'X'.
tbl_bapisditmx-updateflag = 'I'.
tbl_bapisditmx-plant = 'X'.
tbl_bapisditmx-target_qty = 'X'.
tbl_bapisditmx-target_qu = 'X'.
tbl_bapisditmx-item_categ = 'X'.
tbl_bapisditmx-sales_dist = 'X'.
tbl_bapisditmx-dlv_prio = 'X'.
tbl_bapisditmx-prc_group5 = 'X'.
tbl_bapisditmx-cust_mat35 = 'X'.
tbl_bapisditmx-usage_ind = 'X'.
tbl_bapisditmx-route = 'X'.
APPEND tbl_bapisditmx.
ENDFORM. " build_bapi_items
*& Form build_bapi_sched_lines
* Build the BAPI Schedule Lines
FORM build_bapi_sched_lines .
CLEAR tbl_bapischdl.
tbl_bapischdl-itm_number = c_item.
tbl_bapischdl-req_qty = '1'.
tbl_bapischdl-req_date = sy-datum.
APPEND tbl_bapischdl.
ENDFORM. " build_bapi_sched_lines
*& Form build_bapi_conditions
* Pull the BAPI Pricing Conditions from the Contract
FORM build_bapi_conditions .
LOOP AT tbl_bapisdcond.
CLEAR tbl_bapicond.
MOVE-CORRESPONDING tbl_bapisdcond TO tbl_bapicond.
APPEND tbl_bapicond.
CLEAR tbl_bapicondx.
tbl_bapicondx-itm_number = tbl_bapicond-itm_number.
tbl_bapicondx-cond_st_no = tbl_bapicond-cond_st_no.
tbl_bapicondx-cond_count = tbl_bapicond-cond_count.
tbl_bapicondx-cond_type = tbl_bapicond-cond_type.
tbl_bapicondx-updateflag = 'I'.
tbl_bapicondx-cond_value = 'X'.
tbl_bapicondx-currency = 'X'.
tbl_bapicondx-cond_unit = 'X'.
tbl_bapicondx-cond_p_unt = 'X'.
tbl_bapicondx-varcond = tbl_bapicond-varcond.
APPEND tbl_bapicondx.
ENDLOOP.
ENDFORM. " build_bapi_conditions
*& Form call_create_sales_ord_bapi
* Call the Sales Order Create BAPI
FORM call_create_sales_ord_bapi .
CLEAR g_vbeln_created.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = st_bapisdhd1
IMPORTING
salesdocument = g_vbeln_created
TABLES
return = tbl_return
order_items_in = tbl_bapisditm
order_items_inx = tbl_bapisditmx
order_partners = tbl_bapiparnr
order_schedules_in = tbl_bapischdl.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDFORM. " call_create_sales_ord_bapi
*& Form update_sales_ord
* Update the newly created Sales Order with the Pricing Conditions
* from the Contract
FORM update_sales_ord .
CHECK g_valid_contract EQ 'X'.
PERFORM get_contract_details.
PERFORM build_bapi_conditions.
PERFORM call_change_sales_ord_bapi.
ENDFORM. " update_sales_ord
*& Form get_contract_details
* Get Contract Details
FORM get_contract_details .
* Need to manually get the relevant Pricing Conditions as the BAPI
* BAPISDORDER_GETDETAILEDLIST causes problems when we call the BAPI
* BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_SALESORDER_CHANGE (I think
* this is due to the fact that these BAPIs belong to the same Function
* Group and there must be some common structures that are not cleared
* causing us all sorts of grief when we try and call the next BAPI)
DATA: tbl_konv TYPE STANDARD TABLE OF konv WITH HEADER LINE.
DATA: tbl_komv TYPE STANDARD TABLE OF komv WITH HEADER LINE.
DATA: tbl_vbak TYPE STANDARD TABLE OF vbak WITH HEADER LINE.
* Pricing Condition Master
DATA: BEGIN OF tbl_t685a OCCURS 0,
kschl LIKE t685a-kschl,
kaend_wrt LIKE t685a-kaend_wrt,
END OF tbl_t685a.
SELECT *
INTO TABLE tbl_vbak
FROM vbak
WHERE vbeln = c_contract.
READ TABLE tbl_vbak INDEX 1.
SELECT *
INTO TABLE tbl_konv
FROM konv
WHERE knumv = tbl_vbak-knumv AND
kposn = c_item.
CHECK sy-subrc EQ 0.
* We now need to make sure we only bring across the Condition Types that
* are EDITABLE. If we bring across non editable conditions (such as
* 'ZPR1') the Change Sales Order BAPI will fail
SELECT kschl kaend_wrt
INTO TABLE tbl_t685a
FROM t685a
FOR ALL ENTRIES IN tbl_konv
WHERE kappl EQ 'V' AND "Sales
kschl EQ tbl_konv-kschl AND
kaend_wrt EQ 'X' AND "Value is Editable
kmanu NE 'D'. "Process manually
* Prepare for Binary Search
SORT tbl_t685a BY kschl.
LOOP AT tbl_konv.
READ TABLE tbl_t685a WITH KEY kschl = tbl_konv-kschl BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE-CORRESPONDING tbl_konv TO tbl_komv.
APPEND tbl_komv.
ENDIF.
ENDLOOP.
CHECK NOT tbl_komv[] IS INITIAL.
* Map KOMV into the more BAPI friendly BAPISDCOND structure
CALL FUNCTION 'MAP_INT_TO_EXT_STRUCTURE'
TABLES
fxvbak = tbl_vbak
fxkomv = tbl_komv
fxbapikomv = tbl_bapisdcond
EXCEPTIONS
entry_missing = 1
OTHERS = 2.
ENDFORM. " get_contract_details
*& Form call_change_sales_ord_bapi
* Call the Change Sales Order BAPI
FORM call_change_sales_ord_bapi .
DATA: st_head_chg LIKE bapisdh1x,
st_logic_switch TYPE bapisdls.
CHECK NOT g_vbeln_created IS INITIAL.
CHECK g_valid_contract EQ 'X'.
st_head_chg-updateflag = 'U'.
st_logic_switch-cond_handl = 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = g_vbeln_created
order_header_inx = st_head_chg
logic_switch = st_logic_switch
TABLES
return = tbl_return_chg
conditions_in = tbl_bapicond
conditions_inx = tbl_bapicondx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDFORM. " call_change_sales_ord_bapi
*& Form write_output_report
* Produce Output Report
FORM write_output_report .
IF NOT g_vbeln_created IS INITIAL.
WRITE:/ 'Success! Sales Order', g_vbeln_created, 'was created!'.
ELSE.
WRITE:/ 'Failure! Sales Order was not created!'.
ENDIF.
SKIP.
WRITE:/ 'Sales Order Create Log'.
LOOP AT tbl_return.
WRITE:/ tbl_return-type, tbl_return-id, tbl_return-number,
tbl_return-message.
ENDLOOP.
SKIP.
WRITE:/ 'Sales Order Change Log'.
LOOP AT tbl_return_chg.
WRITE:/ tbl_return_chg-type, tbl_return_chg-id,
tbl_return_chg-number, tbl_return_chg-message.
ENDLOOP.
ENDFORM. " write_output_report
*& Form validate_contract
* Make sure that the Contract is Valid
FORM validate_contract .
DATA: l_gueen LIKE vbak-gueen,
l_prsdt LIKE vbkd-prsdt.
SELECT SINGLE vbak~gueen vbkd~prsdt
INTO (l_gueen, l_prsdt)
FROM vbak
INNER JOIN vbkd
ON vbak~vbeln = vbkd~vbeln
WHERE vbak~vbeln = c_contract AND
vbkd~posnr = '000000'.
IF sy-datum LE l_gueen.
* Contract is valid! Set Order Price Date
g_valid_contract = 'X'.
g_cont_price_date = l_prsdt.
ENDIF.
ENDFORM. " validate_contract
Hope this helps.
Cheers,
Pat. -
Hi,
Does anyone know of any open sales orders report ? VA05 ? Table join between VBAP-VBAK ?
ThanksHello,
Does anyone know of any open sales orders report ? VA05 ? Table join between VBAP-VBAK ?
If your basic requirement is find out the open Sales Order then you can look out for the below standard report:
VA05/VA05N
If your requirement involves some values to be included then kindly urge you to go for SQVI technique involving tables like VBAK,VBAP,VBUK and other Sales table based on requirement.
Regards,
Sarthak -
Hi,
What are the tables I should use for the following reports.
1. I want to create sales order status report for given sales office, sales group and creation date.
2. Open sales order report which covers all organizational levels, delivery status, invoice status shipping details and partner function details.
thanks in advance
with regards,
VCFor 2nd Q, you can find the open sales orders in the same VBUK table.
Delivery status field is LFSTK.
Invoice status field is RELIK
The partner information is available in Sales Document: Partner table VBPA. -
Sales Order Created with reference to Contract - Exchange rate Issue
When Sales Order created with reference to contract VBKD fields KURSK and KURSK_DAT gets copied from contract and not redetrmined based on pricing date and Exchange rate type. I expected it to be determined based on pricing date is standard. What I am missing, should it be controlled by data transfers
If Document currency and condition currency are different it cause problems with incorrect condition values are calculated, as KOMP-KURSK are copied from VBKD-KURSK
Any help or directions would be greatly appreciated . We are on 4.7 ISOIL
Sincerely JuliettaWell,
and if we have the same issue, but we don't have OIL Version, but simple 4.6C, which solution has to be applied then?
Thank you
Standa -
Page break problem in Sales Order Report
Hi,
I have made a RTF template for Sales Order Report. The template is designed to contain max 10 lines.
Now if number of lines are less than 10(1 page) or more than 10(2 pages) then PDF output is coming fine.
But if there are exactly 10 lines then instead of printing only 1 page it prints 2 pages, 1st page with 10 lines of data and 2nd page with only header & footer.
Can anybody help?
Regards.How do you define when they page break happens?
Try to use:
<?split-by-page-break:?>
Check the user guide for more information.
Cheers,
Klaus
Maybe you are looking for
-
How to restore a site deleted from SharePoint Designer 2010
Hi All, I have opened a test server site in share point designer 2010, & deleted that particular site in SP designer 2010,can anyone let me know how to restore the site by using SharePoint Designer? I followed below mentioned procedure to restor
-
DNI/NIF not saved in Personal Data
Hi experts, I have a problem, in my iview of Personal Data, when I try to save/change the DNI, when the process finish the DNI/NIF is not saved in the pa20. Why? Thanks in advance, Regards,
-
Addon compatibility between patches
Hi all, I write addons for different customers and of course they are often at different patch levels than I am. How can I make sure that my addon will be compatible with the customer's software? (If I'm at PL 12, and the interop.SAPBOBSCOM.DLL & I
-
Multiple Records with USB-5113
Does the high speed digitizer USB-5133 has the multi-records feature? I tried many ways to program this feature with error "not suffisent memory on board" Need help. Harold Hebert National Research Council Canada
-
HT4463 I am having problems downloading Mountain Lion
I have purchased a new Macbook Pro but as it did not have Mountain Lion already installed, I have purchased this online but have tried over the last 12 hours without success to download it. It keeps failing. Is this a common problem and if so, any