BAPI_CONTRACT_CREATEFROMDATA
Hi,
I am using BAPI : BAPI_CONTRACT_CREATEFROMDATA but I am getting an error Ship-To-Party or Bill-To-Party not found. Although I am giving the customer number in partners table provided. Still i am getting this error. Could anybody please provide any solution.....
Thanks in Advance..
Rajesh
As Ramesh was telling..Pls verify that you have all required data when making the call...
elaborating, make sure that the corresponding 'X' entries are also filled...For example an entry in the Item table requires an entry in the itemx table also...pls read the documentation(Pls ignore this if this is a redundant info that i have said)...
Similar Messages
-
Using BAPI_CONTRACT_CREATEFROMDATA with Configuration data
Am using BAPI_CONTRACT_CREATEFROMDATA BAPI to create a service contract. I need to include the config data also (characteristics & value). As per the documentation one needs to populate CONTRACT_CFGS_VALUE structure for characteristic data.
I am putting the char & value data here but perhaps missing out on something. The service contract gets created but it does not have the char/value data in it. Please help.
Thanks & Regards,
UrmiYes I commit using BAPI function module and thats the reason the contract does get created as per my previous message. But the configuration data does not get created.
Thanks & Regards,
Urmi -
BAPI_CONTRACT_CREATEFROMDATA Billing Plan Tab
In BAPI_CONTRACT_CREATEFROMDATA I cannot figure out how to populate the 'Billing Plan' tab information in the header data. The table that this information is stored in is table FPLA.
Hi,
Do you have and answer about how to complete the billing plan tab?
I also tried to execute BILLING_SCHEDULE_SAVE to create the billing plan information, although the billing plan table gets filled the data does not appear on VA41 in the billing plan table at items level!
Any help would be great, thanks!
Erick -
BAPI_CONTRACT_CREATEFROMDATA document number
Hello,
I'm using the function 'NUMBER_GET_NEXT' for obtaining the next contract document number from the sap system, and I'd like to use this document number with the function 'BAPI_CONTRACT_CREATEFROMDATA'. In other words I want to generate a contract with this function with the document number speficied by me. Is there any way to do that ?
Any help would be greatly appreciated. Thanks in advance.Thank you for the quick answer, Vinod
I am trying to generate an ADRNR number with the function 'ADDR_NUMBER_GET', to populate the ADRC table with some data for the partner adresses.
This function uses the address_reference line where I need to update the APPL_KEY with sy-mandt + VBELN (concatenated). Well, the function successfully generates a document number, let's say 0040000333, but then the BAPI generates the next one, 0040000334.
If I uncomment SALESDOCUMENTIN and set it with the number given by the NUMBER_GET_NEXT FUNCTION, I get an error in the return table, wich tells me to use the external number range (in my case between 0045000000 and 0049999999).
Here's what I do:
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = '09'
object = 'RV_BELEG'
quantity = '1'
" SUBOBJECT = 'AMBI'
TOYEAR = '0000'
IGNORE_BUFFER = ' '
importing
number = l_vbeln
QUANTITY =
RETURNCODE =
exceptions
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
others = 8
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
concatenate sy-mandt l_vbeln into wa_ref-appl_key.
move: 'VBUK' to wa_ref-appl_table,
'VBELN' to wa_ref-appl_field,
'SD01' to wa_ref-addr_group.
call function 'ADDR_NUMBER_GET'
exporting
address_handle = 'AG $00000'
address_reference = wa_ref
personal_address = ' '
NUMBERRANGE_NUMBER = '01'
E071K_WA =
GENERATE_TRANSPORT_ENTRIES =
OWNER = 'X'
TABLE_NAME =
FIELD_NAME =
OBJKEY =
importing
address_number = l_adrnr
RETURNCODE_NUMBERRANGE =
TABLES
E071K_TAB =
EXCEPTIONS
ADDRESS_HANDLE_NOT_EXIST = 1
INTERNAL_ERROR = 2
PARAMETER_ERROR = 3
OTHERS = 4
call function 'BAPI_CONTRACT_CREATEFROMDATA'
exporting
salesdocumentin = l_vbeln
contract_header_in = wa_bapihead
contract_header_inx = wa_bapiheadx
SENDER =
BINARY_RELATIONSHIPTYPE = ' '
INT_NUMBER_ASSIGNMENT = ' '
behave_when_error = 'P'
LOGIC_SWITCH =
testrun = 'X'
convert = 'X'
importing
salesdocument = l_sapdoc
tables
return = it_return
contract_items_in = it_bapiitem
contract_items_inx = it_bapiitemx
contract_partners = it_bapipartn
contract_conditions_in = it_bapicond
contract_conditions_inx = it_bapicondx
CONTRACT_CFGS_REF =
CONTRACT_CFGS_INST =
CONTRACT_CFGS_PART_OF =
CONTRACT_CFGS_VALUE =
CONTRACT_CFGS_BLOB =
CONTRACT_CFGS_VK =
CONTRACT_CFGS_REFINST =
contract_data_in = it_ctr_in
contract_data_inx = it_ctr_inx
CONTRACT_TEXT =
CONTRACT_KEYS =
" extensionin = it_extension
partneraddresses = it_bapiaddr
Edited by: adrian_marchis on Mar 30, 2011 10:27 AM -
Search Example-PGM BAPI_CONTRACT_CREATEFROMDATA
Hallo,
who could provide a demo program with FUBA "BAPI_CONTRACT_CREATEFROMDATA" for the generation of SD-Contracts (VA41).
My utility (procedure, program) only generates the text: "Vendor(selling) receipt still incomplete ...
Furthermore I would like to know in which field to pass the "Fakturaplanart"(Billingplantype/ Field FPART)
Following structure/table/fields (???) is applicable:
> gs_contract_header_in-sales_org = 0100. "gs_esatz-verkorg.
> gs_contract_header_in-doc_type = 'ZZMV'. "gs_esatz-konart.
> gs_contract_header_in-division = 10. "gs_esatz-sparte.
> gs_contract_header_in-distr_chan = 10. "gs_esatz-verweg.
>
>
> gs_contract_header_in-purch_no_c = gs_esatz-vorgnr.
>
> gs_contract_header_in-doc_date = 20060630. "gs_esatz-batdat.
> gs_contract_header_in-req_date_h = 20060630. "gs_esatz-batdat.
> gs_contract_header_in-purch_date = 20060630. "gs_esatz-batdat.
> gs_contract_header_in-serv_date = 20060630. "gs_esatz-batdat.
> gs_contract_header_in-po_dat_s = 20060630. "gs_esatz-batdat.
> gs_contract_header_in-ref_doc_l = 'FAX'. "gs_esatz-vorgnr.
> gs_contract_header_in-ct_valid_f = 20070101. "gs_esatz-vertbeg.
> gs_contract_header_in-ct_valid_t = 20071231. "gs_esatz-vertend.
>
>
> gs_contract_partners-partn_role = 'AG'.
> gs_contract_partners-partn_numb = 000120015.
> APPEND gs_contract_partners TO gt_contract_partners.
>
> gs_contract_data_in-itm_number = 1.
> gs_contract_data_in-val_per = 001.
> gs_contract_data_in-val_per_un = 4. "=>> * Jahr
> gs_contract_data_in-con_st_dat = 20070101. "gs_esatz-vertbeg.
> gs_contract_data_in-con_en_dat = 20071231. "gs_esatz-vertend.
> gs_contract_data_in-canc_proc = '0100'. "gs_esatz-kuendchema.
> APPEND gs_contract_data_in TO gt_contract_data_in.
>
> gs_contract_items_in-itm_number = 1. "gs_esatz-posnum.
> gs_contract_items_in-bill_date = 20060630. "gs_esatz-batdat.
> gs_contract_items_in-material = 00000000000000128."gs_esatz_MATNR
> gs_contract_items_in-target_qty = 0000001. "gs_esatz-Menge
> APPEND gs_contract_items_in TO gt_contract_items_in.
What is wrong?
With regards
AndreasDear John
Please check if any status profile is assigned to the order type you are using. You can check the same from table TVAK, field STSMA.
I guess the status profile is associated and using internal number range for the order type.
In this case before the order is actually saved the object number is temporarily generated. To check the same, try creating an order online and before actualling saving the document. Use menupath: Goto->Header->Status.
Click on the pushbutton "Object Status". Here you will find the object number filled with a temporary generated number which will be later replaced by the actual number with the combination of 'VB' and Order number.
Note that for header the status profile is assigned to Order Type and for items it will assigned to Item Categories. In your case it might be either at Header Level or at Item Level or both.
Also please check in the user-exits if there are any manipulations for the same.
Hope the above info can give you some ways to explore on the same.
Kind Regards
Eswar -
Hi All,
I have a reqiurement where i need to create a contract using either of the function modules SD_SALESDOCUMENT_CREATE or BAPI_CONTRACT_CREATEFROMDATA but i want the data related to partner like sold-to-party in the contract to come from reference document no. but it is not taking values form that referenced document.
Message was edited by:
agarwal ashsihHi,
Look at the below code
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
* SALESDOCUMENT =
SALES_HEADER_IN = IT2_HEADER
* SALES_HEADER_INX =
* SENDER =
* BINARY_RELATIONSHIPTYPE = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* BEHAVE_WHEN_ERROR = ' '
* LOGIC_SWITCH = ' '
* BUSINESS_OBJECT = ' '
* TESTRUN =
* CONVERT_PARVW_AUART = ' '
* STATUS_BUFFER_REFRESH = 'X'
IMPORTING
SALESDOCUMENT_EX = IT2_SALESDOC
* SALES_HEADER_OUT = IT2_HEADERSALES
TABLES
RETURN = IT2_RETURN
SALES_ITEMS_IN = IT2_ORDERITEMSIN
* SALES_ITEMS_INX =
SALES_PARTNERS = IT2_ORDERPARTNERS
SALES_SCHEDULES_IN = IT2_ORDERSCHEDIN
* SALES_SCHEDULES_INX =
SALES_CONDITIONS_IN = IT2_CONDITIONS
* 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 = IT2_ORDERTEXT
* 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 =
Regards
Sudheer -
BAPI_CONTRACT_CREATEFROMDATA - Ship-to-party/Bill-to-party diffrent to SP
Hi All,
I am trying to write create conversion program using 'BAPI_CONTRACT_CREATEFROMDATA'. When ever I use different Ship-to-party/Bill-to-party to that of Sold-to-party BAPI error saying SH/BP customer master doesnt exist. Where as Ship-to-party/Sold-to-party do exist in customer master as SH/BP. Can anyone tell me why BAPI doesnt like Ship-to-party/Bill-to-party different from Sold-to-party.
Regards,
TimHI Tim
To make it simple, can you check in table KNVP with the
Sold-To Party as KUNNR and Sales Org for which you are
creating the order. See if the Ship-to and Bill-To
entries with the number that you are passing exist here.
If yes then it should take, if not it will not take.
Also try to simulate the same case online in VA01 and see
if it can accept that way.
Kind Regards
Eswar -
Contract start and end date in BAPI_CONTRACT_CREATEFROMDATA
HI,
I am using BAPI_CONTRACT_CREATEFROMDATA to create a contract from within a custom ABAP program. However I cannot figure out how to get the contract start and end dates into the contract header. I know that you can enter them into the ONTRACT_DATA_IN table parameter but these dates only appear on the line items and not the header.
Does anyone know which parameters on the function map to the contract header start and end dates.
Thanks.Hi,
there are also fields QT_VALID_F and QT_VALID_T for quotation or inquiry. So it looks like for different contract types you need to use different fields. This BAPI calls FM SD_SALESDOCUMENT_CREATE which has subroutine ms_move_header_in which maps from BAPI fields to internal fields. Here is a small part of this routine.
MOVE order_header_in-qt_valid_f TO e_vbakkom-angdt.
MOVE order_header_in-qt_valid_t TO e_vbakkom-bnddt.
MOVE order_header_in-ct_valid_f TO e_vbakkom-guebg.
MOVE order_header_in-ct_valid_t TO e_vbakkom-gueen.
When I check technical fields for the screen fields "Valid from" and "Valid to" in VA43 I get names GUEBG and GUEEN. So it still looks like you should use CT_VALID_F and CT_VALID_T.
I forgot to mention you can still debug BAPI to figure out where the problem is.
Good luck
Edited by: Martin Voros on Sep 11, 2009 9:57 AM -
How to give Billing plan details to BAPI_CONTRACT_CREATEFROMDATA
Hi,
I am using BAPI-BAPI_CONTRACT_CREATEFROMDATA for creating contract (VA41), the problem is, i am not able to give the billing plan details in this BAPI. I mean, in VA41, in Billing plan tab, it will have 2 fields- Dates From, Dates Until.
These 2 fields i am not able to give in BAPI. Any help is appreciated.
VinothI face same issue now i solve so i tell how to solve
first u use
CALL FUNCTION 'BAPI_CONTRACT_CREATEFROMDATA'
then u commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
after that you can use following FM for billing plan details
CALL FUNCTION 'SD_SALES_BILLINGPLAN_READ'
CALL FUNCTION 'BILLING_SCHEDULE_READ'
CALL FUNCTION 'BILLING_SCHEDULE_SAVE'
CALL FUNCTION 'SD_SALES_DOCUMENT_SAVE'
using above FM u pass all billing plan data if u want sample code give ur mail id because if i past full code then can't read able it it more then 1500 char.
Edited by: kk.adhvaryu on Jun 8, 2010 8:57 AM -
BAPI_CONTRACT_CREATEFROMDATA not defined for sales org distr channel langu
I am using BAPI_CONTRACT_CREATEFROMDATA to create a contract. If I use a material other than a product, I get no error. If I used a product type material< I get an error statign that the material is not defined in sales organisation dirtibution channel langu EN (I have checked the material and it does contain text.
Any ideas what the problem is?
Thanks,
Leannematerial is not extended to the sales org, etc., (see table MVKE) or you're supplying wrong combination of VKORG, VTWEG, SPART values.
-
Technical Object Information in BAPI_CONTRACT_CREATEFROMDATA
We are using BAPI_CONTRACT_CREATEFROMDATA to create contract. While loading, we need to update Equipment Number (Tecnical Objects) into too. However, wea re unable to map the field. Any help?
Hi, I am trying to update the technical objects for the quotation as well. Can you explain a little more what you mean? I am not clear about the idoc setup.
Thanks -
Price in bapi_contract_createfromdata
Hi experts,
I have to create contract which is based on price but in the bapi : BAPI CONTRACTCREATEFROMDATA ,there is no option to input price can anyone help me on this
Thanks in advance
Deepthi
Edited by: deepthi muttavarapu on Mar 8, 2010 7:21 AMHi,
there are also fields QT_VALID_F and QT_VALID_T for quotation or inquiry. So it looks like for different contract types you need to use different fields. This BAPI calls FM SD_SALESDOCUMENT_CREATE which has subroutine ms_move_header_in which maps from BAPI fields to internal fields. Here is a small part of this routine.
MOVE order_header_in-qt_valid_f TO e_vbakkom-angdt.
MOVE order_header_in-qt_valid_t TO e_vbakkom-bnddt.
MOVE order_header_in-ct_valid_f TO e_vbakkom-guebg.
MOVE order_header_in-ct_valid_t TO e_vbakkom-gueen.
When I check technical fields for the screen fields "Valid from" and "Valid to" in VA43 I get names GUEBG and GUEEN. So it still looks like you should use CT_VALID_F and CT_VALID_T.
I forgot to mention you can still debug BAPI to figure out where the problem is.
Good luck
Edited by: Martin Voros on Sep 11, 2009 9:57 AM -
BAPI_CONTRACT_CREATEFROMDATA help needed
Hi all,
A program I have created is required to create multiple contracts during a typical run. In our QA system this works perfectly. However, in our production system, it is able to create the first contract but every contract after that gets an abort message:
"New object number is temporary"
Is there a configuration change that needs to be made from QA to Production? If so, what do I need to do to fix this?
For example, if I have ten contracts numbered 1 through 10 and we process them, number 1 will be created. However, contracts 2 through 10 will be aborted with the same abort message. Again, this works perfectly in QA but not in Production.
Thanks in advance.Dear John
Please check if any status profile is assigned to the order type you are using. You can check the same from table TVAK, field STSMA.
I guess the status profile is associated and using internal number range for the order type.
In this case before the order is actually saved the object number is temporarily generated. To check the same, try creating an order online and before actualling saving the document. Use menupath: Goto->Header->Status.
Click on the pushbutton "Object Status". Here you will find the object number filled with a temporary generated number which will be later replaced by the actual number with the combination of 'VB' and Order number.
Note that for header the status profile is assigned to Order Type and for items it will assigned to Item Categories. In your case it might be either at Header Level or at Item Level or both.
Also please check in the user-exits if there are any manipulations for the same.
Hope the above info can give you some ways to explore on the same.
Kind Regards
Eswar -
Net Price not Updating Using BAPI : BAPI_CONTRACT_CREATE
Dear Experts,
I am facing an issue while creating CONTRACT using the bapi: BAPI_CONTRACT_CREATE. I am creating the Contract based on data from my excel sheet. And we are maintaining the INFO RECORDS for the same materials.
In the excel sheet we are providing the NetPrice (NETPR) and creating the Contract. My issue is " instead of taking the Net Price from the excel it is taking the Net Price from Info Records". For Example, if for a Particular material the Net Price in our excel file is 125, after bapi execution, the net price is updating as 100 instead of 125 in Contract Creation( ME31k-ME33K). In the Info Records we are maintaining this net price(100) for that material.
Thanks in Advance for your response.
Regards,
Prasadyou can use BAPI_CONTRACT_CREATEFROMDATA
* Create Contract Order Number [BAPI_CONTRACT_CREATEFROMDATA]
CALL FUNCTION 'BAPI_CONTRACT_CREATEFROMDATA'
EXPORTING
contract_header_in = header
convert = 'X'
IMPORTING
salesdocument = v_order
TABLES
return = t_return
contract_items_in = itab_item
contract_items_inx = itemx
contract_partners = t_partners
contract_conditions_in = t_conds
contract_conditions_inx = t_condsx
contract_data_in = t_contract
contract_text = t_texts. -
How to display a report in tree format
hai can any one send me the code to display the report in a tree format
if i take example of customer numbers as tree branches and if i click each customer number the tree should expand showing all sales orders for a customer
ragrds
afzaluse FM HR_ALV_HIERSEQ_LIST_DISPLAY
there are 2 internal table , one for header and one for detail
below is code for reference
REPORT zinsd_quot_cont.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbeln_va,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
vkbur TYPE vkbur,
vkgrp TYPE vkgrp,
angdt TYPE angdt_v,
bnddt TYPE bnddt,
kunnr TYPE kunnr,
kwmeng TYPE kwmeng,
meins TYPE meins,
kunwe TYPE kunnr,
name1 TYPE name1_gp ,
name2 TYPE name1_gp ,
sel(1),
expand(1),
salesdocument TYPE bapivbeln-vbeln,
message TYPE bapi_msg,
END OF ty_vbak.
DATA : w_vbak TYPE ty_vbak,
t_vbak TYPE TABLE OF ty_vbak.
DATA : w_update TYPE ty_vbak,
t_update TYPE TABLE OF ty_vbak.
TYPES : BEGIN OF ty_kna1,
kunnr TYPE kunnr,
name1 TYPE name1_gp ,
END OF ty_kna1.
DATA : w_kna1 TYPE ty_kna1,
t_kna1 TYPE TABLE OF ty_kna1.
TYPES : BEGIN OF ty_vbap,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
matnr TYPE matnr,
matkl TYPE matkl,
werks TYPE werks_ext,
kwmeng TYPE kwmeng,
meins TYPE meins,
mvgr5 TYPE mvgr5,
maktx TYPE maktx,
END OF ty_vbap.
DATA : w_vbap TYPE ty_vbap,
t_vbap TYPE TABLE OF ty_vbap.
TYPES : BEGIN OF ty_makt,
matnr TYPE matnr,
maktx TYPE maktx,
END OF ty_makt.
DATA : w_makt TYPE ty_makt,
t_makt TYPE TABLE OF ty_makt.
TYPES : BEGIN OF ty_sum,
vbeln TYPE vbeln_va,
kwmeng TYPE kwmeng,
END OF ty_sum.
DATA : w_sum TYPE ty_sum,
t_sum TYPE TABLE OF ty_sum.
TYPES : BEGIN OF ty_vbpa,
vbeln TYPE vbeln,
posnr TYPE posnr,
parvw TYPE parvw,
kunnr TYPE kunnr,
END OF ty_vbpa.
DATA : w_vbpa TYPE ty_vbpa,
t_vbpa TYPE TABLE OF ty_vbpa.
TYPES : BEGIN OF ty_vbup,
vbeln TYPE vbeln,
posnr TYPE posnr ,
gbsta TYPE gbsta ,
END OF ty_vbup.
DATA : w_vbup TYPE ty_vbup,
t_vbup TYPE TABLE OF ty_vbup.
TYPE-POOLS slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv,
w_fieldcatalog TYPE slis_fieldcat_alv,
w_layout TYPE slis_layout_alv,
gs_keyinfo TYPE slis_keyinfo_alv.
DATA: g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname.
data definition
Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA : g_lines TYPE i.
*Selection Screen
TABLES : vbak,vbap.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
SELECT-OPTIONS s_vkorg FOR vbak-vkorg. " Sales Org
SELECT-OPTIONS s_vtweg FOR vbak-vtweg. " Dist Channel
SELECT-OPTIONS s_spart FOR vbak-spart. " Division
SELECT-OPTIONS s_vkbur FOR vbak-vkbur. " Sales Off
SELECT-OPTIONS s_vkgrp FOR vbak-vkgrp. " Sales Grp
SELECT-OPTIONS s_matkl FOR vbap-matkl. " Mat Grp
SELECT-OPTIONS s_werks FOR vbap-werks. " Plant
SELECT-OPTIONS s_period FOR vbak-angdt. " Sales Off
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM f_getdata.
PERFORM f_initdata.
END-OF-SELECTION.
PERFORM f_createalv.
PERFORM f_dispalv.
*& Form f_getdata
text
--> p1 text
<-- p2 text
FORM f_getdata .
*Sales Header
SELECT
vbeln
vkorg
vtweg
spart
vkbur
vkgrp
angdt
bnddt
kunnr
INTO TABLE t_vbak
FROM vbak
WHERE
vkorg IN s_vkorg " Sales Org
AND vtweg IN s_vtweg " Dist Channel
AND spart IN s_spart " Division
AND vkbur IN s_vkbur " Sales Off
AND vkgrp IN s_vkgrp " Sales Grp
AND angdt IN s_period
AND bnddt IN s_period
AND auart = 'ZQMO'
AND vbtyp = 'B'.
*CUST NAME
SELECT
kunnr
name1
INTO TABLE t_kna1
FROM kna1
FOR ALL ENTRIES IN t_vbak
WHERE
kunnr = t_vbak-kunnr
*Sales Item
SELECT
vbeln
posnr
matnr
matkl
werks
kwmeng
meins
mvgr5
INTO TABLE t_vbap
FROM vbap
FOR ALL ENTRIES IN t_vbak
WHERE
vbeln = t_vbak-vbeln
AND matkl IN s_matkl " Mat Grp
AND werks IN s_werks " Plant
*Partners
SELECT
vbeln
posnr
parvw
kunnr
INTO TABLE t_vbpa
FROM vbpa
FOR ALL ENTRIES IN t_vbak
WHERE
vbeln = t_vbak-vbeln.
IF t_vbpa[] IS NOT INITIAL.
SELECT
kunnr
name1
APPENDING TABLE t_kna1
FROM kna1
FOR ALL ENTRIES IN t_vbpa
WHERE
kunnr = t_vbpa-kunnr
ENDIF.
*Status - Sales Doc
SELECT
vbeln
posnr
gbsta
INTO TABLE t_vbup
FROM vbup
FOR ALL ENTRIES IN t_vbap
WHERE
vbeln = t_vbap-vbeln
AND posnr = t_vbap-posnr
AND gbsta NE 'C'.
SELECT
matnr
maktx
INTO TABLE t_makt
FROM makt
FOR ALL ENTRIES IN t_vbap
WHERE
matnr = t_vbap-matnr
AND spras = 'E'.
ENDFORM. " f_getdata
*& Form f_initdata
text
--> p1 text
<-- p2 text
FORM f_initdata .
SORT t_vbap BY vbeln DESCENDING.
*delete all closed stat items
LOOP AT t_vbap INTO w_vbap.
READ TABLE t_vbup INTO w_vbup
WITH KEY
vbeln = w_vbap-vbeln
posnr = w_vbap-posnr.
IF sy-subrc <> 0.
DELETE t_vbap.
CONTINUE.
ELSE.
READ TABLE t_makt INTO w_makt
WITH
KEY matnr = w_vbap-matnr.
IF sy-subrc = 0.
w_vbap-maktx = w_makt-maktx.
MODIFY t_vbap FROM w_vbap.
ENDIF.
ENDIF.
ENDLOOP.
*find the total quantity
LOOP AT t_vbap INTO w_vbap.
w_sum-vbeln = w_vbap-vbeln.
w_sum-kwmeng = w_vbap-kwmeng.
COLLECT w_sum INTO t_sum.
CLEAR w_sum.
ENDLOOP.
*populate header
LOOP AT t_vbak INTO w_vbak.
Quantity - Total
READ TABLE t_sum INTO w_sum
WITH KEY
vbeln = w_vbak-vbeln.
IF sy-subrc = 0.
w_vbak-kwmeng = w_sum-kwmeng.
ELSE.
CLEAR w_vbak-kwmeng.
ENDIF.
UoM
READ TABLE t_vbap INTO w_vbap
WITH KEY
vbeln = w_vbak-vbeln.
IF sy-subrc = 0.
w_vbak-meins = w_vbap-meins.
ELSE.
CLEAR w_vbak-meins.
ENDIF.
Partner
READ TABLE t_vbpa INTO w_vbpa
WITH KEY
vbeln = w_vbak-vbeln
parvw = 'WE'.
IF sy-subrc = 0.
w_vbak-kunwe = w_vbpa-kunnr.
ELSE.
CLEAR w_vbak-kunwe.
ENDIF.
SHIP TO PARTY NAME
READ TABLE t_kna1 INTO w_kna1
WITH KEY
kunnr = w_vbak-kunwe.
IF sy-subrc = 0.
w_vbak-name2 = w_kna1-name1.
ENDIF.
CUST NAM - SOLD TO PARTY
READ TABLE t_kna1 INTO w_kna1
WITH KEY
kunnr = w_vbak-kunnr.
IF sy-subrc = 0.
w_vbak-name1 = w_kna1-name1.
ENDIF.
MODIFY t_vbak FROM w_vbak.
ENDLOOP.
DELETE t_vbak WHERE kwmeng IS INITIAL.
SORT t_vbak BY vbeln DESCENDING.
SORT t_vbap BY vbeln DESCENDING posnr ASCENDING.
ENDFORM. " f_initdata
*& Form f_createalv
Create Field Cat.
--> p1 text
<-- p2 text
FORM f_createalv .
g_tabname_header = 't_vbak'.
g_tabname_item = 't_vbap' .
CLEAR gs_keyinfo.
gs_keyinfo-header01 = 'VBELN'.
gs_keyinfo-item01 = 'VBELN'.
*VBAK
w_fieldcatalog-fieldname = 'VBELN'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Sales Document'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'VKORG'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Sales Org'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'VTWEG'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Dist Channel'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'SPART'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Division'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'VKBUR'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Sales Office'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'VKGRP'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Sales GRP'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'KUNNR'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Sold to Party'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'NAME1'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-outputlen = 35.
w_fieldcatalog-seltext_l = 'Sold to Party Code - Name'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'KUNWE'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Ship to Party'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'NAME2'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Ship Party Code - Name'.
w_fieldcatalog-outputlen = 35.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'KWMENG'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Quantity'.
w_fieldcatalog-outputlen = 25.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MEINS'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'UoM'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'SALESDOCUMENT'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Document'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MESSAGE'.
w_fieldcatalog-tabname = 't_vbak'.
w_fieldcatalog-seltext_l = 'Log'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
*VBAP
w_fieldcatalog-fieldname = 'POSNR'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'POS'.
w_fieldcatalog-outputlen = 6.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MATNR'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'Material'.
w_fieldcatalog-outputlen = 18.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MAKTX'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'Material Desc'.
w_fieldcatalog-outputlen = 40.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MATKL'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'Material Grp'.
w_fieldcatalog-outputlen = 9.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MVGR5'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'MCNO'.
w_fieldcatalog-outputlen = 4.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'WERKS'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'Plant'.
w_fieldcatalog-outputlen = 91.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'KWMENG'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'Quantity'.
w_fieldcatalog-outputlen = 25.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
w_fieldcatalog-fieldname = 'MEINS'.
w_fieldcatalog-tabname = 't_vbap'.
w_fieldcatalog-seltext_l = 'UoM'.
APPEND w_fieldcatalog TO t_fieldcatalog.
CLEAR: w_fieldcatalog.
LAYOUT
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
w_layout-expand_fieldname = 'EXPAND'.
w_layout-box_fieldname = 'SEL'.
w_layout-box_tabname = 't_vbak'.
ENDFORM. " f_createalv
*& Form f_dispalv
Call ALV
--> p1 text
<-- p2 text
FORM f_dispalv .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = w_layout
it_fieldcat = t_fieldcatalog
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
is_keyinfo = gs_keyinfo
TABLES
t_outtab_header = t_vbak
t_outtab_item = t_vbap
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " f_dispalv
*& Form set_pf_status
PF stat
-->RT_EXTAB text
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZINSD_QUOT_CONT_ST'.
ENDFORM. "set_pf_status
*& Form user_command
Process List UCOMM
-->R_UCOMM text
-->RS_SELFIELD text
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
REFRESH t_update.
IF r_ucomm = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
IF r_ucomm = 'EXECUTE'.
LOOP AT t_vbak INTO w_update
WHERE
sel = 'X'
AND salesdocument = ' '.
APPEND w_update TO t_update.
ENDLOOP.
IF t_update[] IS NOT INITIAL.
LOOP AT t_update INTO w_update.
PERFORM f_bapi_contract_createfromdata USING w_update.
PERFORM f_bdc_contract_from_quotation.
MODIFY t_update FROM w_update.
ENDLOOP.
ELSE.
ENDIF.
PERFORM f_dispalv.
ENDIF.
IF r_ucomm = '&IC1'.
IF rs_selfield-sel_tab_field = 't_vbak-VBELN'.
SET PARAMETER ID 'AGN' FIELD rs_selfield-value.
CALL TRANSACTION 'VA23' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-sel_tab_field = 't_vbak-SALESDOCUMENT' AND
rs_selfield-value NE ' '.
SET PARAMETER ID 'KTN' FIELD rs_selfield-value.
CALL TRANSACTION 'VA43' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM. "user_command
*& Form F_BAPI_CONTRACT_CREATEFROMDATA
BAPI CALL
-->P_W_UPDATE text
FORM f_bapi_contract_createfromdata USING p_w_update STRUCTURE w_update .
DATA : w_contract_header_in TYPE bapisdhd1 ,
w_contract_header_inx TYPE bapisdhd1x ,
t_contract_items_in TYPE TABLE OF bapisditm WITH HEADER LINE,
t_contract_items_inx TYPE TABLE OF bapisditmx WITH HEADER LINE,
t_contract_partners TYPE TABLE OF bapiparnr WITH HEADER LINE,
t_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
CLEAR : w_contract_header_in,
w_contract_header_inx.
REFRESH : t_contract_items_in,
t_contract_items_inx,
t_contract_partners,
t_return.
w_contract_header_in-doc_type = 'ZCNT'.
w_contract_header_in-sales_org = p_w_update-vkorg.
w_contract_header_in-distr_chan = p_w_update-vtweg.
w_contract_header_in-division = p_w_update-spart.
w_contract_header_in-ct_valid_f = p_w_update-angdt.
w_contract_header_in-ct_valid_t = p_w_update-bnddt.
w_contract_header_inx-doc_type = 'X'.
w_contract_header_inx-sales_org = 'X'.
w_contract_header_inx-distr_chan = 'X'.
w_contract_header_inx-division = 'X'.
w_contract_header_inx-ct_valid_f = 'X'.
w_contract_header_inx-ct_valid_t = 'X'.
LOOP AT t_vbap INTO w_vbap
WHERE
vbeln = p_w_update-vbeln.
t_contract_items_in-material = w_vbap-matnr.
t_contract_items_in-plant = w_vbap-werks.
t_contract_items_in-target_qty = w_vbap-kwmeng.
t_contract_items_in-target_qu = w_vbap-meins.
t_contract_items_in-ref_doc = w_vbap-vbeln.
t_contract_items_in-ref_doc_it = w_vbap-posnr.
t_contract_items_in-ref_doc_ca = 'B'.
t_contract_items_in-prc_group5 = w_vbap-mvgr5.
t_contract_items_inx-material = 'X'.
t_contract_items_inx-plant = 'X'.
t_contract_items_inx-target_qty = 'X'.
t_contract_items_inx-target_qu = 'X'.
t_contract_items_inx-ref_doc = 'X'.
t_contract_items_inx-ref_doc_it = 'X'.
t_contract_items_inx-ref_doc_ca = 'X'.
t_contract_items_inx-prc_group5 = 'X'.
APPEND t_contract_items_in.
APPEND t_contract_items_inx.
ENDLOOP.
LOOP AT t_vbpa INTO w_vbpa
WHERE
vbeln = p_w_update-vbeln.
AND posnr = w_vbap-posnr.
t_contract_partners-partn_role = w_vbpa-parvw.
t_contract_partners-partn_numb = w_vbpa-kunnr.
t_contract_partners-itm_number = w_vbpa-posnr.
APPEND t_contract_partners.
ENDLOOP.
CALL FUNCTION 'BAPI_CONTRACT_CREATEFROMDATA'
EXPORTING
SALESDOCUMENTIN =
contract_header_in = w_contract_header_in
contract_header_inx = w_contract_header_inx
SENDER =
BINARY_RELATIONSHIPTYPE = ' '
INT_NUMBER_ASSIGNMENT = ' '
BEHAVE_WHEN_ERROR = ' '
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
salesdocument = p_w_update-salesdocument
TABLES
return = t_return
contract_items_in = t_contract_items_in
contract_items_inx = t_contract_items_inx
contract_partners = t_contract_partners
CONTRACT_CONDITIONS_IN =
CONTRACT_CONDITIONS_INX =
CONTRACT_CFGS_REF =
CONTRACT_CFGS_INST =
CONTRACT_CFGS_PART_OF =
CONTRACT_CFGS_VALUE =
CONTRACT_CFGS_BLOB =
CONTRACT_CFGS_VK =
CONTRACT_CFGS_REFINST =
CONTRACT_DATA_IN =
CONTRACT_DATA_INX =
CONTRACT_TEXT =
CONTRACT_KEYS =
EXTENSIONIN =
PARTNERADDRESSES =
IF p_w_update-salesdocument NE ' ' .
p_w_update-message = 'SUCCESS'.
ELSE.
READ TABLE t_return INDEX 1.
p_w_update-message = t_return-message.
ENDIF.
READ TABLE t_vbak INTO w_vbak
WITH KEY
vbeln = p_w_update-vbeln.
IF sy-subrc = 0.
MODIFY t_vbak INDEX sy-tabix FROM p_w_update .
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDFORM. " F_BAPI_CONTRACT_CREATEFROMDATA
*& Form f_bdc_contract_from_Quotation
BAPI CALL
-->P_W_UPDATE text
FORM f_bdc_contract_from_quotation.
DATA : l_date TYPE char10.
REFRESH : messtab, bdcdata.
CLEAR : messtab, bdcdata.
PERFORM bdc_dynpro USING 'SAPMV45A' '0101'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=COPY'.
PERFORM bdc_field USING 'VBAK-AUART'
'ZCNT'.
PERFORM bdc_dynpro USING 'SAPLV45C' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=RANG'.
PERFORM bdc_dynpro USING 'SAPLV45C' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UEBR'.
PERFORM bdc_field USING 'LV45C-VBELN'
w_update-vbeln.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
IF NOT w_update-angdt IS INITIAL.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = w_update-angdt
IMPORTING
date_external = l_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
PERFORM bdc_field USING 'VBAK-GUEBG'
l_date.
ENDIF.
IF NOT w_update-bnddt IS INITIAL.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = w_update-bnddt
IMPORTING
date_external = l_date
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
PERFORM bdc_field USING 'VBAK-GUEEN'
l_date.
ENDIF.
CALL TRANSACTION 'VA41' USING bdcdata
MODE 'E'
UPDATE 'S'
MESSAGES INTO messtab.
break abap.
READ TABLE messtab WITH KEY msgid = 'V1'
msgnr = '311'.
IF sy-subrc EQ 0.
w_update-message = 'SUCCESS'.
w_update-salesdocument = messtab-msgv2.
ELSE.
READ TABLE messtab WITH KEY msgtyp = 'E'.
IF sy-subrc EQ 0.
DATA : l_info TYPE einfo.
CLEAR l_info.
l_info-msgid = messtab-msgid.
l_info-msgty = messtab-msgtyp.
l_info-msgno = messtab-msgnr.
l_info-msgv1 = messtab-msgv1.
l_info-msgv2 = messtab-msgv2.
l_info-msgv3 = messtab-msgv3.
l_info-msgv4 = messtab-msgv4.
CALL FUNCTION 'MESSAGE_GET_TEXT'
EXPORTING
ieinfo = l_info
ilangu = sy-langu
IMPORTING
etext = w_update-message
EXCEPTIONS
no_t100_found = 1
OTHERS = 2.
ENDIF.
ENDIF.
READ TABLE t_vbak INTO w_vbak WITH KEY vbeln = w_update-vbeln.
IF sy-subrc = 0.
MODIFY t_vbak INDEX sy-tabix FROM w_update transporting message
salesdocument.
ENDIF.
ENDFORM. " f_bdc_contract_from_Quotation
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "bdc_dynpro
Insert field *
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "bdc_field
Maybe you are looking for
-
PI 7.11 process SOAP message with Attachments failed
Hello, we have a scenario where the sender (3rd-Party) start a sync call via PI to a receiver (SAP BW system). The receiver send a response with attachment. SAP processed the message successfully but sender could not processed message because the SOA
-
T400 Fingerprint Software in Windows 7 no longer working
A few days ago, after the usual windows 7 upgrade, the fingerprint prompt to swipe any enrolled finger just disappeared. After several attempts of reinstalling of the fingerprint software what worked is as follows: - From the control panel, Programs
-
How to deactivate withholding tax base amount field
Dear Experts, My in client is using the extended withholding tax with setting Define Formulas for calculating withholding tax, my client feel that the tax base amount field is open and user may accidentally input the wrong amount there thus can anyon
-
I've fiddled with Team Viewer and was able to control my Mac on my PC, but it wasn't over my LAN connection (it was slow), and it was a small windowed view without the Mac's sound. I want to cotrol my Mac, with my PC over LAN and on a 1920x1080 resol
-
IPS host blocking not happening in VLAN 1
Hi I have IDSM2 module installed in 6500 core switch and configured in prismouscous mode. i have added interfaces of 6500 in IPS as blocking device and i can see all the vlan interfaces along with Vlan 1, When i test the attack, i can see the IPS act