WBS creation using BAPI_PROJECT_MAINTAIN
Hi Gurus
We are trying to create a WBS element with custom program. We are succesfully able to create the WBS element but facing errors in positioning the WBS element.
The input for the program is project and parent under which the WBS has to be created. The program is working fine when we create the WBS under a parent which is in CRTD system status. But, when we try to create WBS under a parent which is in REL system status, it is terminating with errors. (Errors: CJ 467 - subhierarchy is not consistent, CJ 280 - Termination - too many errors, CJ 036 - Data cannot be saved). We are using BAPI_PROJECT_MAINTAIN for this.
We have tried to remove all "custom" configuration and go with standard SAP configuration (like investment profile, status profile, field selection, etc).
Can anybody suggest anything that can help us to get through the error?
Thanks a lot in advance,
Hi,
I am using this BAPI without any problems but I don't have access to that system. So maybe you have some issue with data. What you can do is that you will create your project manually in CJ20N and the you will call BAPI BAPI_PROJECT_GETINFO to get info about your project. You can compare your BAPI call with structures for project created manually. It may help you to find a reason for those error messages. You can also try to debug where you are getting those messages.
Cheers
Similar Messages
-
Creating a WBS hierarchy using BAPI_PROJECT_MAINTAIN
Hi,
I am trying to create WBS hierarchy, but i am facing some problem in creating it. The code that i have written is :
DATA : I_PROJECT_DEFINITION LIKE BAPI_PROJECT_DEFINITION OCCURS 0 WITH HEADER LINE,
I_PROJECT_DEFINITION_UPD LIKE BAPI_PROJECT_DEFINITION_UP OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE,
I_METHOD_PROJECT LIKE BAPI_METHOD_PROJECT OCCURS 0 WITH HEADER LINE,
I_WBS_ELEMENT_TABLE LIKE BAPI_WBS_ELEMENT OCCURS 0 WITH HEADER LINE,
I_WBS_HIERARCHIE_TABLE LIKE BAPI_WBS_HIERARCHIE OCCURS 0 WITH HEADER LINE.
CLEAR I_PROJECT_DEFINITION.
I_PROJECT_DEFINITION-PROJECT_DEFINITION = 'TEST_2'.
APPEND I_PROJECT_DEFINITION.
CLEAR I_METHOD_PROJECT.
MOVE 'WBS-Element' TO I_METHOD_PROJECT-OBJECTTYPE.
MOVE 'Create' TO I_METHOD_PROJECT-METHOD.
MOVE 'T1' TO I_METHOD_PROJECT-OBJECTKEY.
MOVE '000001' TO I_METHOD_PROJECT-REFNUMBER.
APPEND I_METHOD_PROJECT.
CLEAR I_METHOD_PROJECT.
MOVE 'WBS-Element' TO I_METHOD_PROJECT-OBJECTTYPE.
MOVE 'Create' TO I_METHOD_PROJECT-METHOD.
MOVE 'T2' TO I_METHOD_PROJECT-OBJECTKEY.
MOVE '000002' TO I_METHOD_PROJECT-REFNUMBER.
APPEND I_METHOD_PROJECT.
CLEAR I_METHOD_PROJECT.
MOVE 'WBS-Element' TO I_METHOD_PROJECT-OBJECTTYPE.
MOVE 'Create' TO I_METHOD_PROJECT-METHOD.
MOVE 'T3' TO I_METHOD_PROJECT-OBJECTKEY.
MOVE '000003' TO I_METHOD_PROJECT-REFNUMBER.
APPEND I_METHOD_PROJECT.
CLEAR I_METHOD_PROJECT.
MOVE 'Save' TO I_METHOD_PROJECT-METHOD.
APPEND I_METHOD_PROJECT.
CLEAR I_WBS_ELEMENT_TABLE.
I_WBS_ELEMENT_TABLE-WBS_ELEMENT = 'T1'.
I_WBS_ELEMENT_TABLE-PROJECT_DEFINITION = I_PROJECT_DEFINITION-PROJECT_DEFINITION.
I_WBS_ELEMENT_TABLE-DESCRIPTION = 'T1'.
APPEND I_WBS_ELEMENT_TABLE.
CLEAR I_WBS_ELEMENT_TABLE.
I_WBS_ELEMENT_TABLE-WBS_ELEMENT = 'T2'.
I_WBS_ELEMENT_TABLE-PROJECT_DEFINITION = I_PROJECT_DEFINITION-PROJECT_DEFINITION.
I_WBS_ELEMENT_TABLE-DESCRIPTION = 'T2'.
APPEND I_WBS_ELEMENT_TABLE.
CLEAR I_WBS_ELEMENT_TABLE.
I_WBS_ELEMENT_TABLE-WBS_ELEMENT = 'T3'.
I_WBS_ELEMENT_TABLE-PROJECT_DEFINITION = I_PROJECT_DEFINITION-PROJECT_DEFINITION.
I_WBS_ELEMENT_TABLE-DESCRIPTION = 'T3'.
APPEND I_WBS_ELEMENT_TABLE.
CLEAR I_METHOD_PROJECT.
MOVE 'WBS-Hierarchy' TO I_METHOD_PROJECT-OBJECTTYPE.
MOVE 'Create' TO I_METHOD_PROJECT-METHOD.
APPEND I_METHOD_PROJECT.
CLEAR I_METHOD_PROJECT.
MOVE 'Save' TO I_METHOD_PROJECT-METHOD.
APPEND I_METHOD_PROJECT.
CLEAR I_WBS_HIERARCHIE_TABLE.
MOVE 'T1' TO I_WBS_HIERARCHIE_TABLE-WBS_ELEMENT.
MOVE I_PROJECT_DEFINITION-PROJECT_DEFINITION TO I_WBS_HIERARCHIE_TABLE-PROJECT_DEFINITION.
MOVE 'T2' TO I_WBS_HIERARCHIE_TABLE-DOWN.
APPEND I_WBS_HIERARCHIE_TABLE.
CLEAR I_WBS_HIERARCHIE_TABLE.
MOVE 'T2' TO I_WBS_HIERARCHIE_TABLE-WBS_ELEMENT.
MOVE I_PROJECT_DEFINITION-PROJECT_DEFINITION TO I_WBS_HIERARCHIE_TABLE-PROJECT_DEFINITION.
MOVE 'T1' TO I_WBS_HIERARCHIE_TABLE-UP.
MOVE 'T3' TO I_WBS_HIERARCHIE_TABLE-RIGHT.
APPEND I_WBS_HIERARCHIE_TABLE.
CLEAR I_WBS_HIERARCHIE_TABLE.
MOVE 'T3' TO I_WBS_HIERARCHIE_TABLE-WBS_ELEMENT.
MOVE I_PROJECT_DEFINITION-PROJECT_DEFINITION TO I_WBS_HIERARCHIE_TABLE-PROJECT_DEFINITION.
MOVE 'T1' TO I_WBS_HIERARCHIE_TABLE-UP.
MOVE 'T2' TO I_WBS_HIERARCHIE_TABLE-LEFT.
APPEND I_WBS_HIERARCHIE_TABLE.
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
EXPORTING
i_project_definition = I_PROJECT_DEFINITION
i_project_definition_upd = I_PROJECT_DEFINITION_UPD
IMPORTING
RETURN = RETURN
tables
i_method_project = I_METHOD_PROJECT
I_WBS_ELEMENT_TABLE_UPDATE =
I_WBS_ELEMENT_TABLE = I_WBS_ELEMENT_TABLE
I_WBS_MILESTONE_TABLE =
I_WBS_MILESTONE_TABLE_UPDATE =
I_WBS_HIERARCHIE_TABLE = I_WBS_HIERARCHIE_TABLE
I_NETWORK =
I_NETWORK_UPDATE =
I_ACTIVITY =
I_ACTIVITY_UPDATE =
I_RELATION =
I_RELATION_UPDATE =
E_MESSAGE_TABLE =
I_ACTIVITY_ELEMENT =
I_ACTIVITY_ELEMENT_UPDATE =
I_ACTIVITY_MILESTONE =
I_ACTIVITY_MILESTONE_UPDATE =
Please can anyone check and tell me what exactly is the problem?
Thank you.Hi Poorvika,
I am facing same problem. If you find solution, can you please post it here?
Thanks
ABAPer -
Code to create WBS using BAPI_PROJECT_MAINTAIN
Hi,
I am creating a program for mass upload of project definition and WBS elements. I was able to create the project definition using BAPI_PROJECTDEF_CREATE. For the WBS, I am using BAPI_PROJECT_MAINTAIN. But I was not able to create WBS yet. Can you give me a sample code for the BAPI_PROJECT_MAINTAIN that can create a WBS? What should be the values to be populated in the table i_method_project, i_wbs_element_table, etc.
Please help.. I will reward points.
Thanks,
LalynHi Lalyn.
Firstly, I would like to suggest you not to use "REWARD POINTS" which is againts the rules of engagement.
Hope you take things positively.
I would like to suggest a couple of references, which are similar to your issue,
[SDN - Reference for Updating value of WBS element - BAPI_PROJECT_MAINTAIN|Update WBS element;
[SDN - Reference for issues related to creation of WBS element using BAPI_PROJECT_MAINTAIN|Problems with BAPI_PROJECT_MAINTAIN;
[SDN Wiki - Standard Reference for ABAP Program to Upload WBS ELEMENTS IN Hierarchy|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2bprogram%2bto%2bupload%2bwbs%2belements%2bin%2bhierarchy ]
Hope that's usefull.
Good Luck & Regards. -
Error in Creating Level2 WBS using BAPI_PROJECT_MAINTAIN
Hi All,
I am trying to Create a WBS-element at Level 2 of an already existing WBS-element using BAPI_PROJECT_MAINTAIN.
I suppose the 'hierarchy table' has to be populated for positioning a WBS in the structure. But I am getting the error 'The transfered hierarchy is inconsistent. Too many errors.'.
I desire to have the following WBS structure in place :
Project Definition : PROJ_DEF
WBS for level 1 : WBS1
WBS for level 2 : WBS2 (This has to be at a sub-node of WBS1,and NOT at the same level as WBS1)
Can some one give me solution to this error, and suggest a way to create the WBS in this pattern.
Regards,
Somil
I have written the following code to populate the hierarchy table :
l_hierarchy-wbs_element = 'WBS1'.
l_hierarchy-project_definition = 'PROJ_DEF'.
l_hierarchy-up = ' '.
l_hierarchy-down = 'WBS2'.
l_hierarchy-right = ' '.
l_hierarchy-left = ' '.
APPEND l_hierarchy TO t_hierarchy_table.
l_hierarchy-wbs_element = 'WBS2'.
l_hierarchy-project_definition = 'PROJ_DEF'.
l_hierarchy-up = 'WBS1'.
l_hierarchy-right = ' '.
l_hierarchy-left = ' '.
l_hierarchy-down = ''.
APPEND l_hierarchy TO t_hierarchy_table.For create the network and the activity I use this:
*** NETWORK ACTIVITY
wa_network-network = '000000000001'.
* wa_network-network_type = 'PS02'.
wa_network-short_text = 'Network'.
wa_network-wbs_element = ld_wbs.
wa_network-project_definition = ld_projdef.
APPEND wa_network TO it_network.
wa_projmethod-objecttype = 'Network'.
wa_projmethod-method = 'Create'.
wa_projmethod-objectkey = ld_wbs.
wa_projmethod-refnumber = '000001'.
APPEND wa_projmethod TO it_projmethod.
CLEAR wa_projmethod.
d_refnumber = '000001'.
wa_activity-network = wa_network-network.
wa_activity-project_definition = ld_projdef.
wa_activity-wbs_element = ld_wbs.
wa_activity-activity = '0010'.
wa_activity-control_key = 'PS02'.
wa_activity-description = 'Activity 1'.
wa_activity-plant = '1000'.
wa_activity-cost_elem = '0000705003'.
wa_activity-purch_org = '1000'.
wa_activity-pur_group = '100'.
wa_activity-matl_group = '90'.
wa_activity-constraint_type_start = '5'.
wa_activity-constraint_type_finish = '5'.
APPEND wa_activity TO it_activity.
CLEAR wa_activity.
wa_projmethod-objecttype = 'NetworkActivity'.
wa_projmethod-method = 'Create'.
wa_projmethod-objectkey = ld_wbs.
wa_projmethod-refnumber = d_refnumber.
APPEND wa_projmethod TO it_projmethod.
d_refnumber = d_refnumber + 1.
CLEAR wa_projmethod. -
How to create services using BAPI_PROJECT_MAINTAIN
Hi Gurus,
I wish to create services ( in Ext Processing tab in tcode CN22) using BAPI_PROJECT_MAINTAIN. Please help me.
Regards
Ajay
Moderator message: please search for available information/documentation before asking, try solving problems yourself first.
Edited by: Thomas Zloch on Dec 8, 2010 2:50 PMHi Lalyn.
Firstly, I would like to suggest you not to use "REWARD POINTS" which is againts the rules of engagement.
Hope you take things positively.
I would like to suggest a couple of references, which are similar to your issue,
[SDN - Reference for Updating value of WBS element - BAPI_PROJECT_MAINTAIN|Update WBS element;
[SDN - Reference for issues related to creation of WBS element using BAPI_PROJECT_MAINTAIN|Problems with BAPI_PROJECT_MAINTAIN;
[SDN Wiki - Standard Reference for ABAP Program to Upload WBS ELEMENTS IN Hierarchy|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2bprogram%2bto%2bupload%2bwbs%2belements%2bin%2bhierarchy ]
Hope that's usefull.
Good Luck & Regards. -
Creating Proj Defn using BAPI_PROJECT_MAINTAIN
Hi all,
I ahve created Proj defn and an WBS element using BAPI_PROJECT_MAINTAIN...
Now i want ot know the procedure to create network header and an activity...
I have created an Network header also....
and i got error while creating an activity
the error reads as
"Relationship type could not converted to the internal format..."
Hw to overcome this error...
thanx in advanceCheck this note
Note 501332 - No type of relationship for BOR 'Network'
if this note does not resolve your problem , then you may need to use conversion exit for Relationship Type. -
Hello ABAPers,
I have been using BAPI_PROJECT_MAINTAIN to create Project and WBS elements and I have done them without any errors.
Now I need help on how to create network activities.
Can anyone share on how to pass data to I_NETWORK table and I_ACTIVITY table and a brief description on what they are ?
Thanks in advance,
KiranHi Kiran,
Do the following steps
1.pass the following to i_method_project
method_project-refnumber = lv_refnum.
method_project-objecttype = 'NETWORK-ACTIVITY'.
method_project-method = 'UPDATE'.
concatenate aufnr(network nr) vornr(activity) into method_project-objectkey.
2.Into i_activity
activity-network = aufnr.
activity-activity = vornr.
3.i_activity_update
activity_update-network = 'X'.
activity_update-activity = 'X'.
It should work.If not let me know.
Rgds,
K.S. -
WBS Element Creation Using BAPI
Friends,
While creating the WBS element using the bapi,
BAPI_BUS2054_CREATE_MULTI I'm getting an error in Return parameter of bapi.the error is
"Individual check for creating the object WBS Element CRA.011 required"
FYI: CRA.011 is nothing but the WBS element which i'm trying to create.
Pls help me in this. Advise me what are the mandatory fields to be passed in the it_wbs_element table of bapi.
Thanks.Hi Karthikeya,
I think the project profile which you are using has a different mask and the WBS element you are passing is different to the BAPI.
Are you able to create manually from CJ01 using the same WBS element?
Create a project manually and it will give the list of the mandatory fields set in the config. Using that list populate the BAPI struture accordingly.
Hope this helps.
Thanks
Lakshman. -
Changes don't reflect using BAPI_PROJECT_MAINTAIN through RFC adapter
Hi,
I am working on a Integration Scenario in XI. In this I am executing BAPIs through RFC adapter. I am using BAPI_PROJECT_MAINTAIN to create WBS Elements in Project System. After creating WBS Elements when I try to define the hierarchy, the BAPI calls executes successfully but the hierarchy is not visible when viewed in the SAP WEB GUI.
I am using following parameters to define WBS hierarchy:
*IMethodProject
OBJECTTYPE = WBS-HIERARCHY
METHOD = CREATE
OBJECTKEY =
REFNUMBER =
OBJECTTYPE =
METHOD = SAVE
OBJECTKEY =
REFNUMBER =
*IProjectDefinition
PROJECT_DEFINITION = P-0300-00-04
*IWbsHierarchieTable
WBS_ELEMENT = WBS-001
PROJECT_DEFINITION = P-0300-00-04
UP =
DOWN = WBS-002
LEFT =
RIGHT =
WBS_ELEMENT = WBS-002
PROJECT_DEFINITION = P-0300-00-04
UP = WBS-001
DOWN =
LEFT =
RIGHT =
In normal case the WBS element 'WBS-002' should move below 'WBS-001', but when I execute BAPI with above parameters, the Hierarchy is not visible in the GUI the both WBS Elements remain at root level, even I get '000' as response with no errors.
When I run the BAPI through transaction SE37 with same parameters as above, the changes are visible in the GUI.
Can anyone please tell what am I missing here.
Thanks & Regards,
AjayHi Ajay,
I understand the problem this way, when u do something thru XI you dont see the effect (even if the the transaction is successful), whereas when it done is directly in the R/3 you can see the output.
look into the below
- check if your XI user is having necessary authorisations (you can do this by enabling the trace in ur R/3 - back end system)
- check if you are passing the input properly in the XI. (like field formats, padding characters, prefixes etc)
Hope this helps to fix ur issue
Regards
Vishnu -
Problem while creating WBS elements using LSMW
Hello experts,
I am able to create Project Definitions using LSMW. (using recording)
But there is a problem while creating WBS elements.
Tcode CJ20 has table control and that will become problem for multiple rows (levels).
Can anyone suggest a solution to mass upload WBS elements?
Thanks for your valuable advice.Hi,
Instead of using "BAPI_PROJECT_MAINTAIN", use following solution. We are using this solution and it is working pretty good.
If the WBS element is already created and you want to create one more with same data, first get the WBS related information using BAPI_PROJECT_GETINFO as you are doing currently.
I am using different sets of BAPIs to create project, create / change WBS element.
I use function module from Function group CJ2001 ( Project related BAPIs ), CJ2054 ( WBS related BAPIs ) and PS_BAPI ( pre/post processing BAPIs ). There are specific order in which you need to execute these BAPIs.
For example if you want to create / change the WBS element, the BAPIs sequence is:
<b>1. BAPI_PS_INITIALIZATION
2. BAPI_BUS2054_CREATE_MULTI ( to create WBS )
or
2. BAPI_BUS2054_CHANGE_MULTI ( to change WBS )
3. BAPI_PS_PRECOMMIT
4. BAPI_TRANSACTION_COMMIT</b>
Check the documentation of BAPI "BAPI_BUS2054_CREATE_MULTI " to see how these function modules work.
Let me know if you need further information.
Regards,
RS -
Error in : Purchase order Creation using BAPI_PO_CREATE1
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
* Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
* Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
* Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
* Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
* Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
* Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP.Hi Shareen,
I think in the following parts of the code,
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa[].
Error in : Purchase order Creation using BAPI_PO_CREATE1
Posted: Mar 20, 2006 7:39 PM Reply E-mail this post
Hell guys,
I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
I want the new PO to have all the characteristics of an existing PO. whose PO # is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in the std FM - MEPO_DOC_ITEM_GET . It raises an exception of failure. I am trying to create many new PO's in the loop below. If there is just one row, sometimes, it creates the PO even with the exception failure ( which is pretty weird).
Am i making any mistake while filling the header or item or schedule lines for the BAPI_PO_CREATE1 ? Any tips or clues why I am getting a dump ?
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = <b>i_ekpa[].</b>
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
<b> poitem = i_bpoi[]
poitemx = i_bpoix[]
poschedule = i_bpos[]
poschedulex = i_bposx[].</b>
it should be only i_bpoi, i_bpoix, i_bpos, i_bposx but not i_bpoi[], i_bpoix[], i_bpos[], i_bposx[].
CHange the code as follows:
DATA: i_insert,
i_create_order,
i_cycle TYPE cycle,
i_qty_acpt TYPE dzmeng,
i_dly_date TYPE vbak-vdatu,
i_item TYPE roijnomiio .
DATA: i_order TYPE symsgv,
i_return TYPE swd_return .
DATA: i_vbak TYPE vbak,
i_vbap TYPE vbap,
i_ekko TYPE ekko,
i_ekpo TYPE ekpo,
i_bsoh TYPE bapisdhd1,
i_bsohx TYPE bapisdhd1x,
i_bpoh TYPE bapimepoheader,
i_bpohx TYPE bapimepoheaderx,
i_vbeln TYPE vbeln_va,
i_posnr TYPE posnr_va,
i_contr TYPE vbeln_va,
i_conit TYPE posnr_va,
i_ebeln TYPE ebeln,
i_ebelp TYPE ebelp,
i_pargr TYPE pargr,
i_thead TYPE thead,
i_line TYPE tline,
i_note TYPE txw_note,
i_new_vbeln TYPE vbeln_va,
i_new_ebeln TYPE ebeln,
i_wa_bsoi TYPE bapisditm,
i_wa_bsoix TYPE bapisditmx,
i_wa_bsop TYPE bapiparnr,
i_wa_bsos TYPE bapischdl,
i_wa_bsosx TYPE bapischdlx,
i_wa_vbpa TYPE vbpa,
i_wa_vbkd TYPE vbkd,
i_wa_bpoi TYPE bapimepoitem,
i_wa_bpoix TYPE bapimepoitemx,
i_wa_bpos TYPE bapimeposchedule,
i_wa_bposx TYPE bapimeposchedulx,
i_wa_bpop TYPE bapiekkop,
i_wa_ekpa TYPE ekpa,
i_message TYPE char72,
i_bapiretn TYPE bapiret2,
i_bapiret2 TYPE TABLE OF bapiret2 INITIAL SIZE 1,
i_vbpa TYPE TABLE OF vbpa INITIAL SIZE 1,
i_vbkd TYPE TABLE OF vbkd INITIAL SIZE 1,
i_ekpa TYPE TABLE OF ekpa INITIAL SIZE 1,
i_bsoi TYPE TABLE OF bapisditm INITIAL SIZE 1,
i_bsoix TYPE TABLE OF bapisditmx INITIAL SIZE 1,
i_bsos TYPE TABLE OF bapischdl INITIAL SIZE 1,
i_bsosx TYPE TABLE OF bapischdlx INITIAL SIZE 1,
i_bsop TYPE TABLE OF bapiparnr INITIAL SIZE 1,
i_bpoi TYPE TABLE OF bapimepoitem INITIAL SIZE 1,
i_bpoix TYPE TABLE OF bapimepoitemx INITIAL SIZE 1,
i_bpos TYPE TABLE OF bapimeposchedule INITIAL SIZE 1,
i_bposx TYPE TABLE OF bapimeposchedulx INITIAL SIZE 1,
i_bpop TYPE TABLE OF bapiekkop INITIAL SIZE 1,
i_text_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_line_tab TYPE TABLE OF tline INITIAL SIZE 1,
i_txw_note TYPE TABLE OF txw_note INITIAL SIZE 1,
i_oij_el_doc_mot TYPE oij_el_doc_mot .
CONSTANTS: c_char_c VALUE 'C',
c_char_e VALUE 'E',
c_char_p VALUE 'P',
c_char_g VALUE 'G',
c_char_i VALUE 'I',
c_char_s VALUE 'S',
c_char_x VALUE 'X',
c_zsw(3) VALUE 'ZSW',
c_nomit_stat(4) VALUE 'ZDNY' .
DATA : lv_nomtk_split TYPE oij_nomtk.
DATA : i_order_split_create TYPE TABLE OF zsws_order_split.
DATA : wa_order_split_create TYPE zsws_order_split.
LOOP AT i_order_split_create INTO wa_order_split_create.
IF NOT i_create_order IS INITIAL .
CLEAR: i_create_order .
MOVE: wa_order_split_create-docnr TO i_ebeln,
wa_order_split_create-docitm TO i_ebelp .
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
IMPORTING
po_ekko = i_ekko
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF .
Fill PO Header
i_bpoh-comp_code = i_ekko-bukrs .
i_bpoh-doc_type = i_ekko-bsart .
i_bpoh-vendor = i_ekko-lifnr .
i_bpoh-langu = i_ekko-spras .
i_bpoh-pmnttrms = i_ekko-zterm .
i_bpoh-purch_org = i_ekko-ekorg .
i_bpoh-pur_group = i_ekko-ekgrp .
i_bpoh-currency = i_ekko-waers .
i_bpoh-agreement = i_ekko-konnr .
i_bpoh-incoterms1 = i_ekko-inco1 .
i_bpoh-incoterms2 = i_ekko-inco2 .
Fill PO update indicator 'X'
i_bpohx-comp_code = c_char_x .
i_bpohx-doc_type = c_char_x .
i_bpohx-vendor = c_char_x .
i_bpohx-langu = c_char_x .
i_bpohx-pmnttrms = c_char_x .
i_bpohx-purch_org = c_char_x .
i_bpohx-pur_group = c_char_x .
i_bpohx-currency = c_char_x .
i_bpohx-agreement = c_char_x .
i_bpohx-incoterms1 = c_char_x .
i_bpohx-incoterms2 = c_char_x .
CALL FUNCTION 'ME_EKPO_SINGLE_READ'
EXPORTING
pi_ebeln = i_ebeln
pi_ebelp = i_ebelp
IMPORTING
po_ekpo = i_ekpo
EXCEPTIONS
no_records_found = 1
OTHERS = 2.
IF sy-subrc <> 0 .
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
Fill PO Item
i_wa_bpoi-po_item = i_ekpo-ebelp .
i_wa_bpoi-material = i_ekpo-matnr .
i_wa_bpoi-plant = i_ekpo-werks .
i_wa_bpoi-stge_loc = i_ekpo-lgort .
i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
i_wa_bpoi-po_unit = i_ekpo-meins .
i_wa_bpoi-tax_code = i_ekpo-mwskz .
i_wa_bpoi-val_type = i_ekpo-bwtar .
i_wa_bpoi-item_cat = i_ekpo-pstyp .
i_wa_bpoi-acctasscat = i_ekpo-knttp .
i_wa_bpoi-agreement = i_ekpo-konnr .
i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
APPEND i_wa_bpoi TO i_bpoi .
Fill PO Item update indicator 'X'
i_wa_bpoix-po_item = i_ekpo-ebelp .
i_wa_bpoix-po_itemx = c_char_x .
i_wa_bpoix-material = c_char_x .
i_wa_bpoix-plant = c_char_x .
i_wa_bpoix-stge_loc = c_char_x .
i_wa_bpoix-quantity = c_char_x .
i_wa_bpoix-po_unit = c_char_x .
i_wa_bpoix-tax_code = c_char_x .
i_wa_bpoix-val_type = c_char_x .
i_wa_bpoix-item_cat = c_char_x .
i_wa_bpoix-acctasscat = c_char_x .
i_wa_bpoix-agreement = c_char_x .
i_wa_bpoix-agmt_item = c_char_x .
APPEND i_wa_bpoix TO i_bpoix .
Fill PO Item Schedule
i_wa_bpos-po_item = i_ekpo-ebelp .
i_wa_bpos-sched_line = '0001' .
i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
APPEND i_wa_bpos TO i_bpos .
Fill PO Item schedule update indicator 'X'
i_wa_bposx-po_item = i_ekpo-ebelp .
i_wa_bposx-sched_line = '0001' .
i_wa_bposx-delivery_date = c_char_x .
i_wa_bposx-quantity = c_char_x .
APPEND i_wa_bposx TO i_bposx .
CLEAR: i_pargr .
SELECT SINGLE pargr
INTO i_pargr
FROM t161
WHERE bstyp = i_ekko-bstyp
AND bsart = i_ekko-bsart .
CLEAR i_ekpa[].
CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
application = c_char_p
ebeln = i_ebeln
bstyp = i_ekko-bstyp
pargr = i_pargr
TABLES
x_ekpa = i_ekpa.
LOOP AT i_ekpa INTO i_wa_ekpa .
i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
i_wa_bpop-langu = sy-langu .
IF NOT i_wa_ekpa-lifn2 IS INITIAL .
i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
ELSE .
i_wa_bpop-buspartno = i_wa_ekpa-parnr .
ENDIF .
APPEND i_wa_bpop TO i_bpop .
CLEAR: i_wa_ekpa, i_wa_bpop .
ENDLOOP .
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = i_bpoh
poheaderx = i_bpohx
IMPORTING
exppurchaseorder = i_new_ebeln
TABLES
return = i_bapiret2
poitem = i_bpoi
poitemx = i_bpoix
poschedule = i_bpos
poschedulex = i_bposx.
i_order = i_new_ebeln .
SHIFT i_order LEFT DELETING LEADING '0' .
i_return-errortype = c_char_i .
i_return-workarea = c_zsw .
i_return-message = '064' .
i_return-variable1 = i_order .
loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
append i_bapiretn to t_bapi_return .
endloop .
if t_bapi_return[] is initial .
i_create_order = c_char_x .
CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
EXPORTING
act_return = i_return. "Popup with new PO no.
ENDCASE . " Docind
ENDIF .
ENDLOOP. -
Not able to update the project using 'BAPI_PROJECT_MAINTAIN'.
I want to create a project , with reference to an already existing project.
I am using 'BAPI_PROJECT_GETINFO' to get the data of the existing project.
The bapi gives the following:
1) e_project_definition.
2) e_wbs_element_table.
3) e_wbs_hierarchie_table
I am passing the u2018e_project_definitionu2019 to 'BAPI_PROJECTDEF_CREATE' to create project.The project is created successfully.
But I am not able to update the project with u2018e_wbs_element_tableu2019
and u2018e_wbs_hierarchie_tableu2019. I am using 'BAPI_PROJECT_MAINTAIN' to update the project.
The program is not giving an error, but it is also not updating the E_WBS_ELEMENT_TABLE and E_WBS_HIERARCHIE_TABLE.
I am attaching the code below.
*& Report ZTEST_PC.
DATA: project_definition TYPE bapipr-project_definition,
with_activities TYPE bapipr-with_activities,
with_milestones TYPE bapipr-with_milestones,
with_subtree TYPE bapipr-with_subtree,
e_project_definition TYPE bapi_project_definition_ex,
return TYPE bapireturn1.
DATA: i_wbs_element_table TYPE TABLE OF bapi_wbs_elements,
e_wbs_element_table TYPE TABLE OF bapi_wbs_element_exp,
e_wbs_milestone_table TYPE TABLE OF bapi_wbs_milestone_exp,
e_wbs_hierarchie_table TYPE TABLE OF bapi_wbs_hierarchie,
e_activity_table TYPE TABLE OF bapi_network_activity_exp,
e_message_table TYPE TABLE OF bapi_meth_message.
DATA: wa_wbs_element_table TYPE bapi_wbs_element_exp,
wa_wbs_hierarchie_table TYPE bapi_wbs_hierarchie.
DATA: l_new_proj_no TYPE prpss-posid.
DATA: l_project_definition TYPE bapi_project_definition.
DATA: l_project_definition_upd TYPE bapi_project_definition_up.
DATA: l_project_definition_stru TYPE bapi_project_definition.
DATA :l_pspnr TYPE ps_intnr,
l_pspid TYPE ps_pspid,
l_pro_def(9) TYPE c.
DATA :l_proj TYPE proj.
DATA :l_len TYPE i VALUE '0'.
DATA: lt_dd03l TYPE TABLE OF dd03l,
ls_dd03l TYPE dd03l.
DATA: fieldname(50), fieldname1(50) TYPE c.
DATA: p_ddic_name(40), struc(40), fun_struc(50) TYPE c.
FIELD-SYMBOLS: <struc>, <c>, <sc>, <def_field> TYPE any.
DATA : i_method_project TYPE TABLE OF bapi_method_project,
wa_method_project TYPE bapi_method_project.
DATA : l_index TYPE bapi_method_project-refnumber.
DATA : it_wbs_element_table TYPE TABLE OF bapi_wbs_element,
it_wbs_hierarchie_table TYPE TABLE OF bapi_wbs_hierarchie.
DATA : wl_wbs_element_table TYPE bapi_wbs_element,
wl_wbs_hierarchie_table TYPE bapi_wbs_hierarchie.
DATA : l_wbs_element_table_update TYPE bapi_wbs_element_update.
DATA : i_wbs_element_table_update TYPE TABLE OF bapi_wbs_element_update.
Get the project info of the Project 'C01.10995'
CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'
EXPORTING
input = 'C01.10995'
IMPORTING
output = project_definition.
CALL FUNCTION 'BAPI_PROJECT_GETINFO'
EXPORTING
project_definition = project_definition
IMPORTING
e_project_definition = e_project_definition
return = return
TABLES
i_wbs_element_table = i_wbs_element_table
e_wbs_element_table = e_wbs_element_table
e_wbs_milestone_table = e_wbs_milestone_table
e_wbs_hierarchie_table = e_wbs_hierarchie_table
e_activity_table = e_activity_table
e_message_table = e_message_table.
Automate the process the process to get the next number for the func module 'CN_SUCHE_FREIE_NUMMER'.
CLEAR : l_pspnr, l_pspnr, l_pspid, l_pro_def.
SELECT MAX( pspnr ) FROM proj INTO l_pspnr.
SELECT SINGLE * FROM proj INTO l_proj WHERE pspnr EQ l_pspnr.
l_pspid = l_proj-pspid.
CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
EXPORTING
input = l_pspid
IMPORTING
output = l_pspid.
l_pro_def = l_pspid+4(5) + 1.
CONDENSE l_pro_def.
CONCATENATE 'C01.' l_pro_def INTO l_pspid .
function module to generate the nect free number between the given range.
CALL FUNCTION 'CN_SUCHE_FREIE_NUMMER'
EXPORTING
search_imp = '2'
prps_s_imp = l_pspid
prps_e_imp = 'C01.29999'
no_dialog = 'X'
IMPORTING
prps_exp = l_new_proj_no.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Update the fields of 'l_project_definition_upd' as 'X' for the fields which has values in 'E_PROJECT_DEFINITION'.
Get the New Project Number.
MOVE-CORRESPONDING e_project_definition TO l_project_definition.
l_project_definition-project_definition = l_project_definition-project_definition+0(3).
l_new_proj_no = l_new_proj_no+4(5).
CONCATENATE l_project_definition-project_definition '.' l_new_proj_no INTO l_project_definition-project_definition.
TRANSLATE l_project_definition-project_definition TO UPPER CASE.
MOVE-CORRESPONDING l_project_definition TO l_project_definition_stru.
Create the New project with the New project Number.
CALL FUNCTION 'BAPI_PROJECTDEF_CREATE'
EXPORTING
project_definition_stru = l_project_definition_stru.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '.
Populate internal table i_method_project for the bapi_project_maintain func module.
CLEAR : wa_wbs_element_table,wl_wbs_element_table,wa_wbs_hierarchie_table,
wl_wbs_hierarchie_table, it_wbs_element_table, it_wbs_hierarchie_table.
CLEAR : wa_method_project, i_method_project, l_index .
l_index = 0.
LOOP AT e_wbs_element_table INTO wa_wbs_element_table.
MOVE-CORRESPONDING wa_wbs_element_table TO wl_wbs_element_table .
APPEND wl_wbs_element_table TO it_wbs_element_table .
wa_method_project-objecttype = 'WBS_ELEMENT'.
wa_method_project-method = 'CREATE'.
wa_method_project-objectkey = wa_wbs_element_table-wbs_element.
l_len = strlen( wa_wbs_element_table-wbs_element ).
Setting Levels as reference number.
CASE l_len.
WHEN '9'.
l_index = 1.
WHEN '12'.
l_index = 2.
WHEN '15'.
l_index = 3.
WHEN '18'.
l_index = 4.
ENDCASE.
wa_method_project-refnumber = l_index .
TRANSLATE wa_method_project-objectkey TO UPPER CASE.
APPEND wa_method_project TO i_method_project.
CLEAR :wa_method_project, l_index.
ENDLOOP.
l_index = l_index + 1.
wa_method_project-refnumber = ' '. "l_index .
wa_method_project-objecttype = ' '. "'WBS_ELEMENT'.
wa_method_project-method = 'SAVE'.
wa_method_project-objectkey = ' '.
APPEND wa_method_project TO i_method_project.
CLEAR wa_method_project.
LOOP AT e_wbs_hierarchie_table INTO wa_wbs_hierarchie_table.
MOVE-CORRESPONDING wa_wbs_hierarchie_table TO wl_wbs_hierarchie_table.
APPEND wl_wbs_hierarchie_table TO it_wbs_hierarchie_table.
ENDLOOP.
Update the fields of 'l_project_definition_upd' as 'X' for the fields which has values in 'E_PROJECT_DEFINITION' respectively.
CLEAR : l_project_definition_upd.
p_ddic_name = 'BAPI_PROJECT_DEFINITION_UP'.
struc = 'l_project_definition_upd'.
fun_struc = 'E_PROJECT_DEFINITION'.
TRANSLATE: p_ddic_name TO UPPER CASE,
struc TO UPPER CASE.
SELECT * FROM dd03l INTO TABLE lt_dd03l WHERE tabname = p_ddic_name.
LOOP AT lt_dd03l INTO ls_dd03l.
ASSIGN ls_dd03l-fieldname TO <c>.
fieldname = ls_dd03l-fieldname .
CONCATENATE fun_struc '-' fieldname INTO fieldname.
ASSIGN (struc) TO <struc>.
ASSIGN COMPONENT <c> OF STRUCTURE <struc> TO <sc>.
ASSIGN (fieldname) TO <def_field>.
IF NOT <def_field> IS INITIAL .
<sc> = 'X'.
ENDIF.
ENDLOOP.
Update the fields of 'l_wbs_element_table_update' as 'X' for the fields which has values in 'e_wbs_element_table' respectively.
READ TABLE e_wbs_element_table INTO wa_wbs_element_table INDEX '1'.
CLEAR : l_wbs_element_table_update, fieldname1, p_ddic_name, struc, fun_struc .
p_ddic_name = 'BAPI_WBS_ELEMENT_UPDATE'.
struc = 'l_wbs_element_table_update'.
fun_struc = 'WA_WBS_ELEMENT_TABLE'.
TRANSLATE: p_ddic_name TO UPPER CASE,
struc TO UPPER CASE.
SELECT * FROM dd03l INTO TABLE lt_dd03l WHERE tabname = p_ddic_name.
LOOP AT lt_dd03l INTO ls_dd03l.
ASSIGN ls_dd03l-fieldname TO <c>.
fieldname = ls_dd03l-fieldname .
CONCATENATE fun_struc '-' fieldname INTO fieldname.
ASSIGN (struc) TO <struc>.
ASSIGN COMPONENT <c> OF STRUCTURE <struc> TO <sc>.
ASSIGN (fieldname) TO <def_field>.
IF NOT <def_field> IS INITIAL .
<sc> = 'X'.
ENDIF.
ENDLOOP.
Append the value of l_wbs_element_table_update TO the table i_wbs_element_table_update for Bapi_project_maintain.
CLEAR i_wbs_element_table_update.
APPEND l_wbs_element_table_update TO i_wbs_element_table_update.
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
EXPORTING
i_project_definition = l_project_definition
i_project_definition_upd = l_project_definition_upd
TABLES
i_method_project = i_method_project
i_wbs_element_table_update = i_wbs_element_table_update
i_wbs_element_table = it_wbs_element_table.
i_wbs_hierarchie_table = it_wbs_hierarchie_table.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '.
Please help me to solve the issue.I am not sure why it is not working?? Try for any other alternate function modules.
But i see one issue with your coding, always check the return table message type and use commit work, instead of sy-subrc check. This fails for BAPI's -
Error while Creating WBS element using BAPI 'BAPI_BUS2054_CREATE_MULTI'
Hi Expert,
I've a requirement to create WBS elements using BAPI. And I am using BAPIs in the following manner.
CALL FUNCTION 'BAPI_PS_INITIALIZATION'
CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'
EXPORTING
i_project_definition = g_pdwbs
TABLES
it_wbs_element = it_wbs_element
et_return = it_return
EXTENSIONIN =
EXTENSIONOUT =
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
When I do so I am getting the below errors. Please suggest.
"Individual check for creating the object WBS Element C-497082 required ".
"Individual check for creating the object WBS Element C-497082-0001 required".
Please suggest how to correct this error.
<REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
Edited by: Alvaro Tejada Galindo on Aug 18, 2008 5:25 PMI am getting the same error, but I cannot figure it out how to detect it and fix it. Will you please share your solution?
Thanks, -
Error with quantity field:Datasource Creation Using Function Module method
Problem with DATASOURCE Creation using Function Module method :
I have created a datasource ZSTANDARD_COST_PRICE using Function Module method . The datasource creation is successfull when I remove the quantity field from the Z table . If I dont remove the quantity field from my Z table it gives an error as "Units Field WAERS for field STPRS of datasource ZSTANDARD_COST_PRICE is hidden". I am not able to remove this error . Please someone guide.
Let me know if my explanation is not clear enough.
Thanks in advance,
Neha.
Z table definition is as below :
MATNR MATNR CHAR 18 0 Material Number
BWKEY BWKEY CHAR 4 0 Valuation area
LFGJA LFGJA NUMC 4 0 Fiscal Year of Current Period
STPRS STPRS CURR 11 2 Standard Price " Here the currency field is WAERS and table T001
PEINH PEINH DEC 5 0 Price Unit
VJSTP VJSTP CURR 11 2 Standard price in previous year
VJPEI VJPEI DEC 5 0 Price unit of previous year.
Edited by: Neha Rathi on Jan 30, 2009 3:03 PMHi,
You should add it as one of the main fields as you have added other fields and not as the currency fields...that is..it should be part of the data source and you should be able to see it in RSO2...
Also if added as i said then it will come as new field in the data source...you can either let it be there...or hide it..
also if you want to populate it then you will have to write the code for this fields as well.
Thanks
Ajeet -
Custom List Form creation using Powershell - SharePoint 2013
Hi,
I have a custom List called 'IssuesList' with 4 fields - "IssueTitle","IssueID","IssueDesc","Status"
While displaying display form I should show 3 fields expect Issue ID i.e. IssueID should be hidden.
and on edit form only Status field should be editable. So using SharePoint designer I created respective Edit form and display forms and changed XSLT to control the display mode on the fields.
I have everything scripted in powershell till now - creation of custom list, publishing pages, webparts etc. however I am looking for how to provision or associate these 2 list forms with IssuesList after I create the list in new site.
I have restrictions on using wsp and site/list template due to business needs. So I need to know if there is any way I can upload these 2 files after I create custom list in powershell and associate them as defaultdisplay and defauteditforms?
Please advise.Hi,
Per my understanding, you might need to apply these custom forms to a list after list creation using PowerShell.
With PowerShell with SharePoint Object Model, we can hide fields on list forms.
The similar thread below with code snippet will provide more information about this:
https://social.technet.microsoft.com/Forums/en-US/ee6fc2eb-197f-4144-94fa-8a4e438675d9/hide-a-field-from-edit-form-list?forum=sharepointgeneralprevious
If there may be other requirements except for hiding fields, as you have limitation on using custom solution package(which should be preferable in such scenario),
a workaround I can provide is that, after list creation, you can add Content Editor Web Part contains the CSS style or JavaScript to the form pages of a specific list, it will help you hide/disable the specific elements, this can be achieved programmatically.
The code below can add a Content Editor Web Part to the DisplayForm of a list(though in C#):
public static void AddCEWP()
SPLimitedWebPartManager manager = null;
SPFile file = null;
using (SPSite site = new SPSite("http://sp"))
using (SPWeb web = site.RootWeb)
try
web.AllowUnsafeUpdates = true;
file = web.GetFile(web.Url + "/Lists/List018/DispForm.aspx");
manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
ContentEditorWebPart webPart = new ContentEditorWebPart();
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("HtmlContent");
//xmlElement.InnerText = "<strong>Hello World!</strong>";
//write the custom CSS style or JavaScript here
string content = "<style>your custom style here...</style>";
xmlElement.InnerText = content;
webPart.Content = xmlElement;
manager.AddWebPart(webPart, "Top", 0);
manager.SaveChanges(webPart);
web.Update();
catch (Exception ex)
//Utility.SPTraceLogError(ex);
finally
if (manager != null)
manager.Dispose();
web.AllowUnsafeUpdates = false;
About how to hide fields on Standard List Forms using jQuery:
http://social.technet.microsoft.com/wiki/contents/articles/21730.sharepoint-2010-conditionally-hide-fields-on-standard-list-forms-using-jquery.aspx
http://stackoverflow.com/questions/10010405/how-to-hide-a-field-in-sharepoint-display-form-based-on-the-field-name-jquery
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
contact [email protected]
Patrick Liang
TechNet Community Support
Maybe you are looking for
-
Error in Downloading and Installing "Pages"
I purchased and started the download of pages via Mac App Store on my brand new MacBook Pro 13". I waited for the app to download, then finally got to the 341.9 MB and still had some left on the download bar but then disappeard from launchpad. So i c
-
Errors encountered while running Java EE tutorial SRDemo in JDeveloper
I am using JDeveloper version 10.1.3.1 to run Java EE tutorial (Web Application) - SRDemo for JSF and EJB 3.0, I got the following error messages while running ServiceRequestFacadeClientEmbed to test the data model (tutorial page 44 of 222), please h
-
Hi experts, I hv configured infotype 41 and in the date type i mentioned the type of activity performed. is there any customization or development that can be done for auto mail generation, when an employee completes his training/probation date that
-
Dear Colleagues, Like Report-Report interface (RRI) in BW, wherein detailed report can be invoked from chart/graph, can similar thing is possible in Visual Composer? Please advice. Regards Pankaj
-
Imessage funktioniert nicht mehr!!!!