BAPI Implementation 'FTR_MAINFLOW_CREATE'
Dear All,
I have done the implementation of 'FTR_MAINFLOW_CREATE'. The data update with these BAPI is very slow and the system throws the dump TSV_TNEW_OCCURS_NO_ROLL_MEMORY or TSV_TNEW_PAGE_ALLOC_FAILED after updating about 400-500 records. Can anyone please explain the reason. The same BAPI works fine for the first 100-200 records. Further is it possible to change the implementation of the BAPI by using parallel processing.
Regards
Virendra Malik
Edited by: Virendra Malik on Nov 8, 2008 12:51 PM
I'm sorry.
I need to create a decrease with dirty price.
My final amount in cash flow for a payment date (decrease + nominal interest) needs to be the same value as I entered in dirty price.
Thank you,
Itajaci Júnior
Similar Messages
-
Find authorization check in BAPI implemented in a program
Dear ,
How can we find the authoruty check in a program in which a BAPI is used.If we search authority check in program click search button and find authority then only the authorization check implemented in program except BAPI is shown not in BAPI.
Kindly send me solution ASAP.
Regard,
Yatendra Sharma
Edited by: yatendra sharma on Mar 19, 2009 12:42 PMHi Yatendra,
May be this code works out for you .It is just a dummy code.Try using Authority Check.Hope your query resolves soon.
authority check
PERFORM <AUTHORITY CHECK> USING <TABLE>.
IF NO_AUTHORITY NE SPACE.
PERFORM BAPIRETURN TABLES RETURN
USING u2018VALUE1'
u2018VALUE2'
u2018VALUE3'
VALUE4
VALUE5.
EXIT.
ENDIF.
Have a best day ahead. -
Hi All,
I have some problem to implement BAPI.
In my BAPI structure i have 4 four fields, they are as follows..
1.naterial number
2.plnat
3.abc indicator
4.total num of records
in this i have to display only the data of abc indicators and in tot num field , i have to disply total num of records of my internal table.
i got the value of total number of records in on varial how to display in my BAPI output?
Anybody pls help me abt this ...
Regards,
pandu.Thank u for ur reply ..
I wnat that internal table record value in the BAPI itself,
What i mean is in BAPI iam displaying MATNR , PLANT and ABCINDICATOR, now addition , one more field i have to add ie TOTNUMREC ie should have total number of records of the internal table.
How do i do for this ?
Regards,
pandu. -
Hellow Everyone
I am starting to learn BAPI.
I understand that BAPI is a remote Enabled Function module.
I am looking for a complete scenario of BAPI use.
I want to understand when and why BAPI is used in a business requirement and where and how I can find them in the SAP system.
please help me for this and I will ake sure to give points for the answer.
ThankyouSome basic tips on BAPI.
It don't have exception and changing parameters.
It's one use is, it is an interface between SAP and NON-SAP.
So you can have front end with .net or java and get business objects from SAP using BAPI.
regards -
External system point of view - BAPI and RFC difference
Hi all,
I have already searched forums and have seen many posts. But none of them are giving exact difference between BAPI and RFC.
Please don't copy paste any previous posts which give differences in definitions and please explain me in simple terms the difference between RFC and BAPI from external system point of view.
Can RFC be used to link SAP to Non-SAP system? If so, why BAPI?
Difference between RFC and RFC Call?
How exception handling is different?
I know that BAPI is based on OOPS concept but if that is the only difference then from external system point of view they should the same.
Regards
VasuHello Vasu
BAPIs implement the so-called "methods" of business objects (like sales order, customer, etc.). However, this OO-concept is just of semantic nature.
I like to make the following equation: BAPI = Dialog (transaction) without dialog
What does this mean? A BAPI executes the very same validations like in the corresponding dialog transaction.
In order to understand the difference between a BAPI and another RFC enabled function module the following hierarchy may be useful:
BAPI = RFC enabled => executes all validations like in dialog transaction
--> RFC module => may execute similar function like BAPI but does NOT execute all validations
--> calls local function modules => execute specific function
but not as comprehensive as a BAPI function
--> may call internal function modules => modules that are intended to be used by SAP only
Regards
Uwe -
when setting up the config for an RFC BAPI synchronous call, it appears that i must have a BAPI on my client side so i can configure the distribution model (BD64) and BAPI destination (BD97) accordingly. Now here's the odd thing. the whole point of this is to call a remote BAPI synchronously. But to set up the config, i must have the BAPI setup on the client, from which i would never call it. ok, the BAPI's method can be any old function module, but is this really how it is done? or am i missing something obvious?
thanksi will call the remote bapi's methods (implemented by the RFC FM on the target system - server) in a bespoke porgram.
in the source system - client, i will use the function module ALE_SYNC_BAPI_GET_RECEIVER to return the rfc destination from BD97 and pass over eg. CALL FUNCTION ZBAPI_MYFUNCTION destination l_var_dest...
should i wish to, i could also call ALE_BAPI_GET_FILTEROBJECTS to interogate the dist mod - BD64, for any filters.
however, i think ... to enter the object and method in either BD64 or BD97, i must have to create the object's method's bapi in my source system - client. to do this, i have to actually create a function module, release it, create the method for my object, use the function module i have just created, make it an API type in the method, then release it in the method.
this is all well and good it you want to use any functionality implemented by a BAPI on the system the BAPI is created on, however, i am trying to call a remote BAPI.
the BAPI implementation on the client, has nothing to do with the BAPI call on the server. it does not even have to be called the same, nor require the same interface. it purely exists for the population of BD64 and BD97.
i hope what i have written is getting nearer to the point.
cheers christian
glen -
What is badi?difference between bapi and badi?
what is badi?difference between bapi and badi?
Hi..
BADI is just an object-oriented version of user-exit. Instead of entering program code into some function module (as in customer-exit), you define some class which has to implement predefined methods and those methods are fired at predefined points just like an old user-exit. Some BADI can have multiple independent implementations which is much better for software deployment as several developers can implement the same BADI independently.
To understand BAPIs, you must know that there are 2 things. One is the SAP Object Repository of the Business Object Repository (BOR) and the Function Builder.
Now the business objects with their business processes and business data, reside in the BOR, with the corresponding BAPI. the implementation of this BAPI resides in the function builder. Any external world (non SAP) programs or legacy systems can access the business processes or data of any business object in the BOR, thru the process of invoking the BAPI implementation of the BAPI for this business object.
Thus we can access a business object.
So we can say that a BAPI is a process that allows third party s/w or non SAP programs to access SAP Business object data and processes.
<REMOVED BY MODERATOR>
Regards
- Rishika
Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:33 PM -
Problem in posting Custom fields in Purchase Order using BAPI_PO_CREATE1
Hi friends,
Did any body tried populating custom fields using BAPI_PO_CREATE1?
I am trying to populate custom fields in Header.
I am populating EXTENSIONIN-STRUCTURE with 'BAPI_TE_MEPOHEADER' and EXTENSIONIN-VALUEPART1 with respective values of fields using the code below.
T_CUSTDATA_IN-PROJECT_ID_NUM = '543211'.
T_CUSTDATA_INX-PROJECT_ID_NUM = 'X'.
MOVE 'BAPI_TE_MEPOHEADER' TO T_EXTENSIONIN-STRUCTURE.
*CLEAR T_BAPI_TE_PO_HEADER-PO_NUMBER.
MOVE-CORRESPONDING T_CUSTDATA_IN TO T_BAPI_TE_MEPOHEADER.
MOVE 'T_BAPI_TE_MEPOHEADER' TO T_EXTENSIONIN-VALUEPART1.
APPEND T_EXTENSIONIN.
MOVE 'BAPI_TE_MEPOHEADERX' TO T_EXTENSIONIN-STRUCTURE.
*CLEAR T_BAPI_TE_PO_HEADER-PO_NUMBER.
MOVE-CORRESPONDING T_CUSTDATA_INX TO T_BAPI_TE_MEPOHEADERX.
MOVE 'T_BAPI_TE_MEPOHEADERX' TO T_EXTENSIONIN-VALUEPART1.
APPEND T_EXTENSIONIN.
But still it is not populating the custom fields.
Can some body help me on this?
Thanks & Regards,
Ramesh KodavatiHi,
You require to implement the Badi ME_BAPI_PO_CUST
Method MAP2I_EXTENSIONIN or INBOUND
for changing the parameter CH_EXTENSIONIN in method INBOUND
or CH_STRUC in method MAP2I_EXTENSIONIN.
in addition to passing the extensionin parameters in bapi.
implement the above said bapi and put a break point in both of the methods (exactly i don't remember)
and check values are populating in the CH_STRUC structure.
Regards,
Dwaraka.S -
XI / PI Alert Framework to Populate an ABAP table
We are sending an outbound proxy to PI, and if an error occurs in PI, we want to populate an abap table in the source system. SAP has told us this could only be done via the PI alert framework. Could someone tell me if there is one or many user exits (and what they are) in the PI alert framework that abap code could be inserted in?
BAPI- Implementation of interface IF_EX_ALERT_MODIFY_TEXT.
-
Problem passing a table parameter in rfc call using the function control
I try to pass a Table as parameter to a Function Module using the SAP.Functions library (part of SAP frontend controls) from a Visual Basic (VBA) program.
The function module has been verified to work when invoked from SAP FrontEnd Function Builder.
The SAP RFC Control is created with
Set sapFunctions=CreateObject("SAP.Functions")
Following code snippet shows how I attempt to set exports and add a table row before calling the function module:
sapFunctions.Connection = sapConnection
Set sapMaterialUpd = sapFunctions.Add("Z_SD_BAPI_SALES_DATA_UPD")
With sapMaterialUpd
<i>'set exports</i>
.Exports("PA_GLPUPDLEVEL") = "S"
.Exports("PA_VKORG") = "FI14"
<i>'append table row</i>
.Tables("IT_SALES_DATA_UPD").AppendRow
.Tables("IT_SALES_DATA_UPD")(1, "VKORG") = "FI14"
.Tables("IT_SALES_DATA_UPD")(1, "MATNR") = "W_3100"
.Tables("IT_SALES_DATA_UPD")(1, "DATBI") = "99991231"
.Tables("IT_SALES_DATA_UPD")(1, "DATAB") = "20041231"
.Tables("IT_SALES_DATA_UPD")(1, "KBETR") = "2222"
.Tables("IT_SALES_DATA_UPD")(1, "KONWA") = "EUR"
End With
<i>'call the function module</i>
If sapMaterialUpd.Call() = True Then
<i>'do something with the return tables here...</i>Else
Debug.Print sapMaterialUpd.Exception
End If
The Call() returns <b>FALSE</b> and the exception is <b>"SYSTEM_FAILURE"</b>. The connection also resets.
The local logfile that the control generates shows that an exception occurs at the point of the call:
<i>10.02.2005 17:54:20.766 Packing Parameters for Z_SD_BAPI_SALES_DATA_UPD
Packing Parameter PA_GLPUPDLEVEL.
Packing Parameter PA_VKORG.
Packing Table 0.
Packing Table 1.
10.02.2005 17:54:20.766 *** Calling RFC Function 'Z_SD_BAPI_SALES_DATA_UPD'
10.02.2005 17:54:20.986 RFC CALL status = RFC_SYS_EXCEPTION
10.02.2005 17:54:20.986 RFC Error: RFC_IO27
-Status:CODE=CM_DEALLOCATED_NORMAL STATUS=CM_NO_STATUS_RECEIVED DATA=CM_COMPLETE_DATA_RECEIVED ID=69415076
-Message:connection closed
-Internal Status:IO HANDLE=23 DRV=EXT LINE=1420 CODE=27 : GET ID=ffff LINE=861 CODE=7
10.02.2005 17:54:20.986 Function call finished.</i>
Seen next code snippet. If the Table object is not touched, the function call goes through without any problems:
sapFunctions.Connection = sapConnection
Set sapMaterialUpd = sapFunctions.Add("Z_SD_BAPI_SALES_DATA_UPD")
With sapMaterialUpd
'set exports
.Exports("PA_GLPUPDLEVEL") = "S"
.Exports("PA_VKORG") = "FI14"
'do <b>not</b> append a table row, for testing only ;-)</b>
End With
<i>'call the function module</i>
If sapMaterialUpd.Call() = True Then
<i> 'do something with the return tables here...</i>
Else
Debug.Print sapMaterialUpd.Exception
End If
This code works perfectly when calling the function. It returns TRUE and behaves normally. The function module returns descriptive response text in a table telling that the table was empty, according to the BAPI implementation.
So is there something special needed here <i>after</i> appending the table row and <i>before</i> making the Call to properly attach the table as a parameter for the function module?
Can this be a bug in the SAP RFC Control? The version of the wdtfuncs.ocx is 6206.6.45.54.
Any hints are welcome!hi All partner,
who solved this problem , I meet it too and
can't clear it.
SAPfunc := sapfunctions1.Add('z_get_sfcs_dn_mo');
SAPitab := sapfunc.tables.item ('I_DNMO');
SAPitab.appendrow; SAPitab.value(1,'MANDT') := '220';
SAPitab.Value(1,'VBELN') := '2150000001';
SAPitab.Value(1,'POSNR') := '50';
SAPitab.value(1,'MATNR') := '19-99999-00';
SAPitab.value(1,'AUFNR') := '921241512001';
SAPitab.value(1,'DEDAT') := '2005/09/09';
SAPitab.value(1,'LFIMG') := '100';
IF SAPfunc.call = true then
begin
end
else
begin
showmessage('call fail!!') ;
end;
end;
RFC source code as below
FUNCTION z_get_sfcs_dn_mo.
""Local interface:
*" TABLES
*" I_DNMO STRUCTURE ZDN_MO
data: wa type zdn_mo.
LOOP AT i_dnmo.
wa-mandt = i_dnmo-mandt.
wa-vbeln = i_dnmo-vbeln.
wa-posnr = i_dnmo-posnr.
wa-matnr = i_dnmo-matnr.
wa-aufnr = i_dnmo-aufnr.
wa-dedat = i_dnmo-dedat.
wa-lfimg = i_dnmo-lfimg.
modify zdn_mo from wa.
insert into zdn_mo values wa. --dump at here
commit work.
ENDLOOP.
T/C: ST22 error message say at
insert into zdn_mo values wa. ---dump at here
the sapfunc.call returns fail.
Message was edited by: jorry wang -
Cascade SyncBos not work correctly
Hi,
we have a parent SyncBo called Y01_ORD_TR and other child SyncBos Y02_ANOM.
An user have a register in his mobile device, then we replicate, and this register is deleted from table merep_207.
Then the user have a modification of this register and sincronize it.
In the sincronization process the system return the next error message for Y01_ORD_TR :
Record not on device
Return code 1 (DOWNLOADER)
and the next message for Y02_ANOM:
Related SyncBO Y01_ORD_TR with Sync key 0000017057 is not present on the device.
Return code 1 (DOWNLOADER)
Then if I reprocess the record of the SyncBo Y01_ORD_TR it works correctly and modify it in R/3 without exist the record in MI (it was deleted from table merep_207 during the replication).
Can anybody tell mewhy is it happens???
Thanks, regards.Hi Jose,
For the error message :- MI is an offline solution and at any point of time backend is the boss and we have to follow the backend. If backend deleted a record, it will be removed from RDB and hence it will be delted from all devices from next sync. But the problem here is the record will be visible in the device til he syncs and he can modify the record with out knowing that its deleted from the backend..
Now there are two business scenarios here..
1. Once the data is deleted, no updates are allowed. If the data is actually deleted (not soft delete or archieved), then there is no chance to modify it.
2. Another scenario requires the data modified from the device user to be updated so that there should not be any data loss. (otherwise modification from the device user will be lost).
MI supports both these scenarios, based on the parameter settings. By default its the first scenario.
If you enable REPROCESS_ON_NO_DATA parameter to 'X', it works as scenario 2. The updates are allowed, ofcourse subject to the backend validation in modify bapi wrapper.
MI will call GetDetail bapi wrapper to fetch the data from the backend and then merge the device changes to it and then call modify bapi wrapper. If either of these bapis fail, then the data won't be updated in the backend. Obiously no conflict checking done here and the data will be overwritten in the backend (based on modify bapi implementation). Because of this, we want this to happen only during reprocessing (not during normal sync from user) which is ofcourse triggered by admin who is aware of the consequences.
Hope its clear to you..
Regards
Ajith -
I have created a JCO Function Module Listener to be triggered after a BAPI in R/3 is called.
I have made the following modifications to the modification-config.xml:
<function-module-listener>
<param name="fmevent:ZBAPISDORDER_GETDETAILEDLIST" value="com.xxx.listeners.ZBAPISDORDER_GETDETAILEDLIST_Listener" />
</function-module-listener>
The default BAPI implementation has been changed with a new BAPI. I have made the configuration changes to refer to the new BAPI and the new BAPI also is getting called. Should I register for Function Module listener to the Original one or to the modified BAPI name..
When I execute this BAPI, the Function Module listener class is not getting called. I have a debug statement to write to the logs at the start of the "connectionEvent" method and seems this itself is not getting called.
Should I register this class to be notified for events..
Please letme know if there are any configuration to be made from the SAP side or from SAP J2EE Engine to get this done.
Thanks & Regards,
D.VinodhVinodh
<b>Should I register for Function Module listener to the Original one or to the modified BAPI name..</b>
--> I hope it should registered for Modified One !!!
Thanks
Jack
Allot points if it helps !!! -
BAPI_OPPORTUNITY_CREATEMULTI
Can someone please show me an example of how to use this BAPI to create CRM Sub-Opportunities - have been struggling for several days. Am creating a simple prototype prg to see if feasible at-this-time. Sub-Opps already exist in the system, I just want to add/assign them to a Master CRM rec.
Seems like I only need 3 param tables:
1. HEADER - is this for the Master Rec or do you build header based on sub-opp info/guid?
2. OPPORTUNITY - seems clear but am not sure about fields REF_HANDLE & REF_GUID. Are these for the master rec or the opportunity?
3. INPUT_FIELDS - everyone has trouble with this:
lt_InputFields-REF_HANDLE = ? "N(10)
lt_InputFields-REF_GUID = ? "C(32)
lt_InputFields-REF_KIND = ? "C(01)
lt_InputFields-OBJECTNAME = ? "C(30)
lt_InputFields-LOGICAL_KEY = ? "C(42)
lt_InputFields-FIELDNAME = ? "C(30)
lt_InputFields-CHANGEABLE = ? "C(1)
I have tried the following alternate strategies too, maybe
1. Debug main transaction CRMD_BUS2000111 (Maintain Opportunities) at point of saving sub-opps but I cannot find where the save occurs to see how SAP does it. Ran SE30 on it and found some functions that look promising but when I set a break-point on a specific func-name, it never stops!
2. Function CRM_WAP_OPP_CREATE() actually calls BAPI_OPPORTUNITY_CREATEMULTI and it seems much-much simpler because it requires a minimal number of parameters but I get nothing.
If anyone can help, I promise to upload my final prototype here for others.Below is a complete prototype program that exercises the CRM OPPORTUNITY BAPIs. It should run as-is, since no special tables or text-elements are used. I did not use EVERY table parameter available to the BAPIs, but this is a good start.
As I promised, once I got these working - I wanted to post my results. I hope this may be useful and serve as a big relief for the next guy.
Program Name: ZJRC_CRMBAPI01 (SAP vers 4.7, CRM 4.0)
Description : Test program for the CRM Opportunity BAPI's.
: CRM_OPPORTUNITYCRM_BAPI BAPI Implementations:
: BAPI_OPPORTUNITY_GETDETAILMUL Read Opportunities
: BAPI_OPPORTUNITY_CREATEMULTI Generate Opportunities
: BAPI_OPPORTUNITY_CHANGEMULTI Change Opportunities
: BAPI_OPPORTUNITY_DELETEMULTI Delete Opportunities
: Once the concepts are proven, a function module will
: will created for Steven J. Lee to call from his
: modified CRM opportunity screen.
Parameters : None
Called from : SE38/SA38
Calls to :
Internal : 1. L_Main() - main body.
: 2. L_GetGUID() - returns guid based on obj_id #.
: 3. L_GetOppInfo() - calls BAPI_OPPORTUNITY_GETDETAILMU()
: 4. L_CreateOpp() - calls BAPI_OPPORTUNITY_CREATEMULTI()
: 5. L_BldCHeader() - builds header param itab.
: 6. L_BldCOpp() - builds opportunity param itab.
: 7. L_BldCOrg() - builds organization param itab.
: 8. L_BldCCustH() - builds customer_head itab.
: 9. L_BldCFields() - builds input_fields itab. (Partner too)
:10. L_LinkOpp() - calls BAPI_OPPORTUNITY_CHANGEMULTI()
:11. L_CheckOpen() - if order is open, cannot save.
:12. L_ChangeOpp() - calls BAPI_OPPORTUNITY_CHANGEMULTI()
:13. L_DeleteOpp - calls BAPI_OPPORTUNITY_DELETEMULTI()
:14. L_OutPut() - displays guid info and bapi results.
:15. L_DispSubOpps()- displays linked sub-opp guid info.
:16. L_ClearITabs() - clears various global itabs.
External : 1. BAPI_OPPORTUNITY_GETDETAILMUL()
: 2. BAPI_OPPORTUNITY_CREATEMULTI()
: 3. BAPI_OPPORTUNITY_CHANGEMULTI()
: 4. BAPI_OPPORTUNITY_DELETEMULTI()
: 5. BAPI_TRANSACTION_COMMIT()
: 6. GUID_CREATE() - not implemented.
: 7. POPUP_TO_INFORM()
: 8. POPUP_TO_CONFIRM_STEP()
: 9. CRM_ORDERADM_H_GUID_GET_OW() - get guid by Obj_Id. (Cuzed problems.)
:10. GET_FIELDTAB_REMOTE() - get list of fieldnames.
Coupling : None
Files used :
SAP files : 1. CRMD_ORDERADM_H = get guid via Obj_Id directly when function
: CRM_ORDERADM_H_GUID_GET_OW() cuzed problems.
I-TABS : 1. Many for bapi's, none for other purposes.
Returns : None
Examples : 1. *-- As called from SE38/SA38.
: ZJRC_CRMBAPI01
Revision His:
JRC, 05/25/05 - initial.
REPORT ZJRC_CRMBAPI01.
*-- Constants.
CONSTANTS: NO(1) TYPE C VALUE ' ',
YES(1) TYPE C VALUE 'X'.
*-- INCLUDES:
INCLUDE <ICON>.
*-- Tables
*-- BAPI GET-INFO tables. (Global because I use them here/there to "seed"
corresponding tables for the CREATE/CHANGE/DELETE bapi's. For example,
if delete, the header info is the same. However, you must be careful
because the structures are seldom identical requiring a move-corresponding.)
!!! NOTE !!! - don't forget to also add any new itabs here to module
L_ClearITabs at the end of this prg. If not, you may get duplicate
recs in the itab for each call to L_GetOppInfo().
DATA: ith_GetGUID TYPE TABLE OF BAPIBUS20001_GUID_DIS WITH HEADER LINE,
ith_GetHEADER TYPE TABLE OF BAPIBUS20001_HEADER_DIS WITH HEADER LINE,
ith_MastHeader TYPE TABLE OF BAPIBUS20001_HEADER_DIS WITH HEADER LINE,
ith_GetORG TYPE TABLE OF BAPIBUS20001_ORGMAN_DIS WITH HEADER LINE,
ith_GetPARTNER TYPE TABLE OF BAPIBUS20001_PARTNER_DIS WITH HEADER LINE,
ith_GetOPP TYPE TABLE OF BAPIBUS20001_OPPORTUNITY_DIS WITH HEADER LINE,
ith_GetCustH TYPE TABLE OF BAPIBUS20001_CUSTOMER_H_DIS WITH HEADER LINE,
ith_GetDOCFLOW TYPE TABLE OF BAPIBUS20001_DOC_FLOW_DIS WITH HEADER LINE,
ith_GetReturn TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
*-- BAPI CREATE tables. (Declared global so output can be display at end of report.)
DATA: ith_CreReturn TYPE TABLE OF BAPIRET2 WITH HEADER LINE,
ith_CreSaved TYPE TABLE OF BAPIBUS20001_OBJECT_ID WITH HEADER LINE,
ith_CreCreated TYPE TABLE OF BAPIBUS20001_HEADER_INS WITH HEADER LINE.
*-- BAPI CHANGE tables. (Declared global so output can be display at end of report.)
DATA: ith_ChgReturn TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
*-- BAPI DELETE tables. (Declared global so output can be display at end of report.)
DATA: ith_DelObjs TYPE TABLE OF BAPIBUS20001_OBJECT_ID WITH HEADER LINE,
ith_DelReturn TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
*-- When using a Tab control in conjunction with my "OK/EXIT"
buttons, I need this to go to the START-OF-SELECTION event
when the OK button is clicked and controlled from the
AT SELECTION-SCREEN event.
TABLES: SSCRFIELDS.
********************[ USER INPUT SCREEN ]*********************
*--[ Selection Screen Title ]--
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 1(60) T_0Title.
SELECTION-SCREEN SKIP 1.
*--[ START SCRN BLOCK 1 ]--
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T_1Title.
SELECTION-SCREEN BEGIN OF LINE.
*-- Master CRM key.
SELECTION-SCREEN COMMENT 1(10) T_CRMKey.
PARAMETERS: S_CRMKey(10) TYPE C DEFAULT '369'.
*-- Display master opportunity info.
SELECTION-SCREEN PUSHBUTTON 25(11) T_OKBut USER-COMMAND OK.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
*--[ START SCRN BLOCK 2 ]--
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE T_2Title.
SELECTION-SCREEN BEGIN OF LINE.
*-- Enter sub-opp key to clone from.
SELECTION-SCREEN COMMENT 1(10) T_SubOp1.
PARAMETERS: S_SubOp1(40) TYPE C DEFAULT '(Cloned from master nnn)' LOWER CASE.
*-- Add Sub-Opp button.
SELECTION-SCREEN PUSHBUTTON 55(15) T_AddSOP USER-COMMAND ADDSOP.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
*--[ START SCRN BLOCK 3 ]--
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE T_3Title.
SELECTION-SCREEN BEGIN OF LINE.
*-- Enter sub-opp key to link to master.
SELECTION-SCREEN COMMENT 1(10) T_LnkKey.
PARAMETERS: S_LnkKey(10) TYPE C DEFAULT '725'.
*-- Link Sub-Opp button.
SELECTION-SCREEN PUSHBUTTON 25(15) T_LnkSOP USER-COMMAND LNKSOP.
*-- Un-Link Sub-Opp button.
SELECTION-SCREEN PUSHBUTTON 45(15) T_ULkSOP USER-COMMAND ULKSOP.
*-- Delete Sub-Opp button.
SELECTION-SCREEN PUSHBUTTON 65(15) T_DELSOP USER-COMMAND DELSOP.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B3.
*--[ OK/EXIT ]--
*-- Ok/Exit pushbuttons. (Actually, OK is DISPLAY above.)
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN PUSHBUTTON 40(11) T_EXBut USER-COMMAND EXIT.
*--[ INFORMATION ]--
SELECTION-SCREEN SKIP 1.
*-- Set Break point(s).
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: S_Break AS CHECKBOX DEFAULT ' ' MODIF ID BUG.
SELECTION-SCREEN COMMENT 3(31) T_BugTxt MODIF ID BUG.
SELECTION-SCREEN END OF LINE.
********************[ INITIALIZATION ]*********************
INITIALIZATION.
*-- Global vars.
DATA: g_Ok(1) TYPE C VALUE YES,
g_RunWhat(10) TYPE C,
g_MastGuid TYPE GUID_32,
g_BlankGuid TYPE GUID_32 VALUE '00000000000000000000000000000000',
g_LogicalKey1(4) TYPE N VALUE '0001'.
*-- Screen elements.
*-- Title
CONCATENATE SY-REPID '-' 'CRM BAPI OPPORTUNITY TEST01'
INTO T_0Title SEPARATED BY SPACE.
T_1Title = 'Master Opportunity'.
*-- Block1 selections.
T_CRMKey = 'CRM Key:'.
*-- Block2 selections.
T_2Title = 'Create Opp'.
T_AddSOP = 'Clone Opp'.
T_SubOp1 = 'Desc 2:'.
*-- Block3 selections.
T_3Title = 'Link/Delete Opp'.
T_LnkKey = 'Link Key:'.
T_LnkSOP = 'Link SubOpp'.
T_ULkSOP = 'UnLink SubOpp'.
T_DelSOP = 'Delete SubOpp'.
*-- Ok/Exit
T_OKBut = '@15@Ok'.
T_OKBut = 'Display'.
T_EXBut = '@2O@Exit'.
T_BugTxt = 'Activate break points.'.
GET PARAMETER ID 'MGU' FIELD S_MGuid.
********************[ AT SELECTION-SCREEN ]********************
AT SELECTION-SCREEN.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-- User pressed the continue or exit button?
g_RunWhat = SY-UCOMM.
CASE g_RunWhat.
WHEN 'ADDSOP' OR 'LNKSOP' OR 'ULKSOP' OR 'DELSOP'.
*-- Goto START-OF-SELECTION event...
SSCRFIELDS-UCOMM = 'ONLI'.
WHEN 'OK' OR 'ONLI'. "OK button or SAP F8.
*-- Goto START-OF-SELECTION event...
SSCRFIELDS-UCOMM = 'ONLI'.
WHEN 'HELP1'.
*-- Goto START-OF-SELECTION event...
SSCRFIELDS-UCOMM = 'ONLI'.
WHEN 'EXIT'.
LEAVE.
WHEN OTHERS.
IF SY-UCOMM IS INITIAL. "Pressed ENTER on some prompt.
*-- Here's your chance to update something on screen.
ENDIF.
ENDCASE.
********************[ START-OF-SELECTION ]*********************
START-OF-SELECTION.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-- What pushbutton was selected.
CASE g_RunWhat.
WHEN 'OK' OR 'ONLI' OR 'ADDSOP' OR 'LNKSOP' OR 'ULKSOP' OR 'DELSOP'.
*-- Start the report.
PERFORM L_Main.
ENDCASE.
********************[ START L_Main() ]*********************
FORM L_Main.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-- For Delete, the obj_id in the "CRM Key:" input field is not
* used. We are going to delete whatever obj_id is in the
* "Link Key:" prompt so store it to CRMKey and pretend it's
* the master. This way lookups will validate it. For Link/Unlink
* we must still validate that the master CRM Key exists.
IF g_RunWhat EQ 'DELSOP'.
S_CRMKey = S_LnkKey.
ENDIF.
*-- Get GUID for Master-Opportunity.
PERFORM L_GetGUID USING S_CRMKey CHANGING g_MastGuid g_Ok.
CHECK g_Ok = YES.
*-- Save Master-Opportunity info.
PERFORM L_GetOppInfo USING g_MastGuid CHANGING g_Ok.
CHECK g_Ok = YES.
*-- Store master info and place result in header.
ith_MastHeader[] = ith_GetHEADER[].
READ TABLE ith_MastHeader INDEX 1.
*-- What action?
CASE g_RunWhat.
WHEN 'ADDSOP'.
*-- Create/Clone Sub-Opportunity from Master Opportunity.
PERFORM L_CreateOpp CHANGING g_Ok.
WHEN 'LNKSOP' OR 'ULKSOP'.
*-- Link or UnLink Sub-Opportunity to Master.
PERFORM L_LinkOpp USING g_RunWhat S_CRMKey S_LnkKey CHANGING g_Ok.
WHEN 'DELSOP'.
*-- Delete Sub-Opportunity.
PERFORM L_DeleteOpp USING S_LnkKey CHANGING g_Ok.
ENDCASE.
CHECK g_Ok = YES.
*-- Get Master-Opportunity info again before output
* in case we added or linked something. If Delete
* do NOT re-get info because we deleted it and
* the GETDETAIL info BAPI would now fail.
IF g_RunWhat NE 'DELSOP'.
PERFORM L_ClearItabs.
PERFORM L_GetOppInfo USING ith_MastHeader-GUID CHANGING g_Ok.
ENDIF.
*-- Diplay GUIDs, Opportunities, BAPI messages, etc.
PERFORM L_OutPut.
*-- END Output.
WRITE: / 'END:', SY-UZEIT.
*-- End report.
NEW-PAGE PRINT OFF.
ENDFORM.
********************[ END L_Main() ]*******************
********************[ START L_GetGUID() ]*******************
FORM L_GetGUID USING P_CRMKey CHANGING P_Guid p_Ok.
*-- Local vars.
DATA: L_CRMKey(10) TYPE C,
L_TmpTxt3(45) TYPE C,
L_LookupMode(1) TYPE C VALUE '1'. "Tried two ways to get guid.
*-- For SAP function CRM_ORDERADM_H_GUID_GET_OW() - if used.
DATA: ET_GuidKey TYPE CRMT_OBJECT_GUID_TAB,
EV_GuidKey TYPE CRMT_OBJECT_GUID.
*-- For manually getting guids from table CRMD_ORDERADM_H.
DATA: BEGIN OF L_TabGuids OCCURS 0,
GUID LIKE CRMD_ORDERADM_H-GUID,
OBJECT_ID LIKE CRMD_ORDERADM_H-OBJECT_ID,
END OF L_TabGuids.
*-- Default to YES, if error will set to NO below.
p_OK = YES.
*-- Format CMR key. (ie: 369 must be '0000000369')
l_CRMKey = P_CRMKey.
SHIFT l_CRMKey RIGHT DELETING TRAILING SPACE.
OVERLAY l_CRMKey WITH '0000000000'.
*-- How do you want to retrieve GUID?
CASE L_LookupMode.
WHEN '1'.
*-- Get GUID directly from order-admin table for id.
SELECT GUID OBJECT_ID
FROM CRMD_ORDERADM_H INTO TABLE L_TabGuids
WHERE OBJECT_ID = l_CRMKey AND
OBJECT_TYPE = 'BUS2000111'. "Opportunity
IF SY-SUBRC = 0.
READ TABLE L_TabGuids INDEX 1.
P_Guid = L_TabGuids-GUID.
ELSE.
p_Ok = NO.
l_TmpTxt3 = 'was not found. Try again.'.
ENDIF.
WHEN '2'.
*-- This function works, but it sometimes retrieves multiple GUIDs
* for the same CRMKey/ObjID - which messes me up. Maybe there are
* different kinds of "objects" for the same id? Thought using the
* OBJECT_TYPE = 'BUS2000111' might work but no. Decided to use the
* direct SELECT on CRMD_ORDERADM_H above.
*-- Get GUID for CRM object.
CALL FUNCTION 'CRM_ORDERADM_H_GUID_GET_OW'
EXPORTING
IV_OBJECT_ID = L_CRMKey "Object ID ie: 12
IV_OBJECT_TYPE = 'BUS2000111'
IMPORTING
ET_ORDERADM_H_GUID = ET_GuidKey
EV_ORDERADM_H_GUID = EV_GuidKey
EXCEPTIONS
RECORD_NOT_FOUND = 1
OBJECT_ID_IS_NOT_UNIQUE = 2
OTHERS = 3.
IF SY-SUBRC EQ 0.
P_Guid = EV_GuidKey.
ELSE.
p_Ok = NO.
CASE SY-SUBRC.
WHEN 1.
l_TmpTxt3 = 'was not found. Try again.'.
WHEN 2.
l_TmpTxt3 = 'was not unique. Maybe linked already?'.
WHEN OTHERS.
l_TmpTxt3 = 'OTHER error msg. ???'.
ENDCASE.
ENDIF. "Failed
ENDCASE. "L_LookupMode
*-- Display fail msg.
IF p_Ok = NO.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'INVALID CRM NUMBER'
TXT1 = 'CRM Number'
TXT2 = l_CRMKey
TXT3 = l_TmpTxt3.
ENDIF.
ENDFORM.
********************[ END L_GetGUID() ]*******************
********************[ START L_GetOppInfo() ]*******************
FORM L_GetOppInfo USING p_GuidKey CHANGING p_Ok.
*-- Local vars.
DATA: L_LCnt TYPE I.
*-- Local tables. (Use these if you want to examine output of
the GET BAPI. They are not used anywhere else.)
DATA: lth_ITEM TYPE TABLE OF BAPIBUS20001_ITEM_DIS WITH HEADER LINE,
lth_TEXT TYPE TABLE OF BAPIBUS20001_TEXT_DIS WITH HEADER LINE,
lth_STATUS TYPE TABLE OF BAPIBUS20001_STATUS_DIS WITH HEADER LINE,
lth_PRODUCT TYPE TABLE OF BAPIBUS20001_PRODUCT_DIS WITH HEADER LINE,
lth_SALES TYPE TABLE OF BAPIBUS20001_SALES_DIS WITH HEADER LINE,
lth_CUSTOMER_ITEM TYPE TABLE OF BAPIBUS20001_CUSTOMER_I_DIS WITH HEADER LINE,
lth_EXTENSIONOUT TYPE TABLE OF BAPIPAREX WITH HEADER LINE,
lth_APPOINTMENT TYPE TABLE OF BAPIBUS20001_APPOINTMENT_DIS WITH HEADER LINE,
lth_SERVICE_OS TYPE TABLE OF BAPIBUS20001_SERVICE_OS_DIS WITH HEADER LINE,
lth_LISTOFRELATIONS TYPE TABLE OF BAPIRELLK WITH HEADER LINE,
lth_PRICING TYPE TABLE OF BAPIBUS20001_PRICING_DIS WITH HEADER LINE,
lth_PRICING_ITEM TYPE TABLE OF BAPIBUS20001_PRICING_ITEM_DIS WITH HEADER LINE,
lth_SCHEDULE TYPE TABLE OF BAPIBUS20001_SCHEDLIN_DIS WITH HEADER LINE,
lth_SCHEDULE_ITEM TYPE TABLE OF BAPIBUS20001_SCHEDLIN_ITEM_DIS WITH HEADER LINE,
lth_CONFIG_CFG TYPE TABLE OF BAPIBUS20001_CONFIG_CUCFG_DIS WITH HEADER LINE,
lth_CONFIG_BLB TYPE TABLE OF BAPIBUS20001_CONFIG_CUBLB_DIS WITH HEADER LINE,
lth_CONFIG_INS TYPE TABLE OF BAPIBUS20001_CONFIG_CUINS_DIS WITH HEADER LINE,
lth_CONFIG_PRT TYPE TABLE OF BAPIBUS20001_CONFIG_CUPRT_DIS WITH HEADER LINE,
lth_CONFIG_VAL TYPE TABLE OF BAPIBUS20001_CONFIG_CUVAL_DIS WITH HEADER LINE,
lth_CONFIG_VK TYPE TABLE OF BAPIBUS20001_CONFIG_CUVK_DIS WITH HEADER LINE,
lth_CONFIG_REF TYPE TABLE OF BAPIBUS20001_CONFIG_CUREF_DIS WITH HEADER LINE,
lth_LIKE_ITEM TYPE TABLE OF BAPIBUS20001_STRUCTURE_DIS WITH HEADER LINE,
lth_CUMULATED_H TYPE TABLE OF BAPIBUS20001_CUMULATED_H_DIS WITH HEADER LINE.
*-- Initialize GUID tab.
CLEAR ith_GetGUID. REFRESH ith_GetGUID.
ith_GetGUID-GUID = p_GuidKey.
APPEND ith_GetGUID.
*------------[ GET OPPORTUNITY INFO ]--------------
CALL FUNCTION 'BAPI_OPPORTUNITY_GETDETAILMUL'
TABLES
GUID = ith_GetGUID "<== Global
HEADER = ith_GetHEADER "<== Global
ITEM = lth_ITEM
OPPORTUNITY = ith_GetOPP "<== Global
PARTNER = ith_GetPARTNER "<== Global
ORGANISATION = ith_GetORG "<== Global
TEXT = lth_TEXT
STATUS = lth_STATUS
PRODUCT = lth_PRODUCT
SALES = lth_SALES
CUSTOMER_HEAD = ith_GetCustH "<== Global
CUSTOMER_ITEM = lth_CUSTOMER_ITEM
EXTENSIONOUT = lth_EXTENSIONOUT
RETURN = ith_GetRETURN "<== Global
APPOINTMENT = lth_APPOINTMENT
SERVICE_OS = lth_SERVICE_OS
LISTOFRELATIONS = lth_LISTOFRELATIONS
PRICING = lth_PRICING
PRICING_ITEM = lth_PRICING_ITEM
SCHEDULE = lth_SCHEDULE
SCHEDULE_ITEM = lth_SCHEDULE_ITEM
CONFIG_CFG = lth_CONFIG_CFG
CONFIG_BLB = lth_CONFIG_BLB
CONFIG_INS = lth_CONFIG_INS
CONFIG_PRT = lth_CONFIG_PRT
CONFIG_VAL = lth_CONFIG_VAL
CONFIG_VK = lth_CONFIG_VK
CONFIG_REF = lth_CONFIG_REF
LIKE_ITEM = lth_LIKE_ITEM
CUMULATED_H = lth_CUMULATED_H
DOC_FLOW = ith_GetDOCFLOW. "<== Global
*-- Check header for results.
DESCRIBE TABLE ith_GetHEADER LINES L_LCnt.
IF L_LCnt > 0.
p_Ok = YES.
ELSE.
MESSAGE i000(crm0) WITH 'Error retrieving header for GUID.'.
p_Ok = NO.
ENDIF.
ENDFORM.
*******************[ END L_GetOppInfo() ]********************
*******************[ START L_CreateOpp() ]********************
FORM L_CreateOpp CHANGING p_OK.
*-- Local vars.
DATA: L_Answer(1) TYPE C,
lth_Text LIKE TLINE OCCURS 0,
l_TmpDesc LIKE BAPIBUS20001_HEADER_INS-DESCRIPTION. "C(40)
*-- Default this.
p_OK = YES.
*-- Prompt user.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
DEFAULTOPTION = 'Y'
TEXTLINE1 = 'Ready to CREATE Opportunity?'
TEXTLINE2 =
TITEL = 'CREATE OPPORTUNITY'
CANCEL_DISPLAY = ' ' "Hide the CANCEL button
IMPORTING
ANSWER = L_Answer.
IF L_Answer <> 'J'.
p_Ok = NO.
EXIT.
ENDIF.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-------------[ RE-GET MASTER OPP INFO AGAIN ]-------------
*-- Start with all empty itabs.
PERFORM L_ClearITabs.
*-- Get GUID for Master-Opportunity.
PERFORM L_GetGUID USING S_CRMKey CHANGING g_MastGuid p_Ok.
CHECK p_Ok = YES.
*-- Get Master-Opportunity info.
PERFORM L_GetOppInfo USING g_MastGuid CHANGING p_Ok.
CHECK p_Ok = YES.
*---------[ Build BAPI Table Params ]-----------
DATA: lth_CHeader TYPE TABLE OF BAPIBUS20001_HEADER_INS WITH HEADER LINE,
lth_COpp TYPE TABLE OF BAPIBUS20001_OPPORTUNITY WITH HEADER LINE,
lth_COrg TYPE TABLE OF BAPIBUS20001_ORGMAN_INS WITH HEADER LINE,
lth_CPartner TYPE TABLE OF BAPIBUS20001_PARTNER_INS WITH HEADER LINE,
lth_CPricing TYPE TABLE OF BAPIBUS20001_PRICING WITH HEADER LINE,
lth_CCustH TYPE TABLE OF BAPIBUS20001_CUSTOMER_H WITH HEADER LINE,
lth_CFields TYPE TABLE OF BAPIBUS20001_INPUT_FIELDS WITH HEADER LINE.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*---------[ Build Header itab ]-----------
PERFORM L_BldCHeader TABLES lth_CHeader.
*---------[ Build Opportunities itab ]-----------
PERFORM L_BldCOpp TABLES lth_COpp.
*---------[ Build Organization itab ]-----------
PERFORM L_BldCOrg TABLES lth_COrg.
*---------[ Build Pricing itab ]-----------
PERFORM L_BldCPricing TABLES lth_CPricing lth_COpp.
*---------[ Build CustomerHead itab ]-----------
PERFORM L_BldCCustH TABLES lth_CCustH.
*---------[ Build Input_Fields itab ]-----------
* Note, Partner itab is built here too.
PERFORM L_BldCFields TABLES lth_CFields lth_CPartner.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*---------[ CREATE NEW OPPORTUNITY ]-----------
CALL FUNCTION 'BAPI_OPPORTUNITY_CREATEMULTI'
EXPORTING
TESTRUN = ' '
TABLES
HEADER = lth_CHeader
OPPORTUNITY = lth_COpp
ORGANISATION = lth_COrg
PARTNER = lth_CPartner
TEXT =
PRODUCT =
PRICING = lth_CPricing "<== Needed for CURRENCY.
INPUT_FIELDS = lth_CFields
CREATED_PROCESS = ith_CreCreated
RETURN = ith_CreReturn
SAVED_PROCESS = ith_CreSaved
ITEM =
SCHEDULELINE =
APPOINTMENT =
SERVICE_OS =
STATUS =
CUSTOMER_HEAD = lth_CCustH. "<== For SAIC detail data.
CUSTOMER_ITEM =
DOCUMENT_FLOW =
PRICING_ITEM =
CONFIG_CFG =
CONFIG_BLB =
CONFIG_INS =
CONFIG_PRT =
CONFIG_VAL =
CONFIG_VK =
CONFIG_REF =
CONDITION_CREATE =
EXTENSIONIN = .
*-- The new Opportunity will not appear until you commit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDFORM.
*******************[ END L_CreateOpp() ]********************
*******************[ START L_BldCHeader() ]********************
FORM L_BldCHeader TABLES lth_CHeader STRUCTURE BAPIBUS20001_HEADER_INS.
*-- Use Master header fields. Structures are different between
* the GETDETAIL and CREATE BAPI's so we have to map.
READ TABLE ith_GetHEADER INDEX 1.
MOVE-CORRESPONDING ith_GetHEADER TO lth_CHeader.
CLEAR lth_CHeader-GUID. "Contains guid from master rec.
CLEAR lth_CHeader-OBJECT_ID. "ie: 000000369
lth_CHeader-GUID = g_BlankGuid.
lth_CHeader-HANDLE = 1. "<== Set this and NO SAVE at all unless ALL are set.
lth_CHeader-PROCESS_TYPE = 'OISU'. "ith_HEADER-PROCESS_TYPE = ZMST
lth_CHeader-BIN_RELATION_TYPE = 'MASU'.
APPEND lth_CHeader.
ENDFORM.
*******************[ END L_BldCHeader() ]********************
*******************[ START L_BldCOpp() ]********************
FORM L_BldCOpp TABLES lth_COpp STRUCTURE BAPIBUS20001_OPPORTUNITY.
*-- Local vars.
DATA: L_RHandle LIKE BAPIBUS20001_OPPORTUNITY-REF_HANDLE VALUE 1,
L_TmpC10(10) TYPE C,
L_TmpDesc2 LIKE BAPIBUS20001_OPPORTUNITY-DESCRIPTION_OPP. "C(40)
*-- Structures are slightly different between
* the GETDETAIL and CREATE BAPI's.
READ TABLE ith_GetOPP INDEX 1.
MOVE-CORRESPONDING ith_GetOPP TO lth_COpp.
lth_COpp-REF_HANDLE = L_RHandle. "<== Set this and NO 2nd Desc line saved unless ALL are set.
lth_COpp-REF_GUID = g_BlankGuid.
L_TmpDesc2 = S_SubOp1.
IF S_SubOp1 IS INITIAL OR S_SubOp1 CS '(Cloned from master nnn)'.
CONCATENATE S_CRMKey ')' INTO L_TmpC10.
CONCATENATE '(Cloned from master' L_TmpC10 INTO L_TmpDesc2
SEPARATED BY SPACE.
ENDIF.
lth_COpp-DESCRIPTION_OPP = l_TmpDesc2."<== 2nd line of desc.
APPEND lth_COpp.
ENDFORM.
*******************[ END L_BldCOpp() ]*******************
*******************[ START L_BldCOrg() ]*******************
FORM L_BldCOrg TABLES lth_COrg STRUCTURE BAPIBUS20001_ORGMAN_INS.
*-- Structures are slightly different between
* the GETDETAIL and CREATE BAPI's.
READ TABLE ith_GetORG INDEX 1.
MOVE-CORRESPONDING ith_GetORG TO lth_COrg.
CLEAR lth_COrg-REF_GUID.
lth_COrg-REF_GUID = g_BlankGuid.
lth_COrg-REF_HANDLE = 1.
APPEND lth_COrg.
ENDFORM.
*******************[ END L_BldCOrg() ]*******************
*******************[ START L_BldCPricing() ]*******************
FORM L_BldCPricing TABLES lth_CPricing STRUCTURE BAPIBUS20001_PRICING
lth_COpp STRUCTURE BAPIBUS20001_OPPORTUNITY.
*-- Make sure opportunity info is in header.
READ TABLE lth_COpp INDEX 1.
*-- Needed to store CURRENCY.
CLEAR lth_CPricing.
lth_CPricing-REF_HANDLE = 1.
lth_CPricing-REF_GUID = g_BlankGuid.
lth_CPricing-REF_KIND = 'A'.
lth_CPricing-CURRENCY = lth_COpp-CURRENCY.
lth_CPricing-CURRENCY_ISO = lth_COpp-CURRENCY_ISO.
APPEND lth_CPricing.
CLEAR lth_CPricing.
ENDFORM.
*******************[ END L_BldCPricing() ]*******************
*******************[ START L_BldCCustH() ]*******************
FORM L_BldCCustH TABLES lth_CCustH STRUCTURE BAPIBUS20001_CUSTOMER_H.
*-- Structures are slightly different between
* the GETDETAIL and CREATE BAPI's.
READ TABLE ith_GetCustH INDEX 1.
MOVE-CORRESPONDING ith_GetCustH TO lth_CCustH.
CLEAR lth_CCustH-REF_GUID.
lth_CCustH-REF_GUID = g_BlankGuid.
lth_CCustH-REF_HANDLE = 1.
APPEND lth_CCustH.
ENDFORM.
*******************[ END L_BldCCustH() ]*******************
*******************[ START L_BldCFields() ]*******************
FORM L_BldCFields TABLES lth_CFields STRUCTURE BAPIBUS20001_INPUT_FIELDS
lth_CPartner STRUCTURE BAPIBUS20001_PARTNER_INS.
*---------[ Admin Rec ]---------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'ORDERADM_H'.
lth_CFields-REF_KIND = ' '. "A <== No effect setting to A or leave blank.
lth_CFields-LOGICAL_KEY = '0001'.
lth_CFields-FIELDNAME = 'DESCRIPTION'.
APPEND lth_CFields.
*---------[ Opportunity ]---------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'OPPORT_H'.
lth_CFields-REF_KIND = 'A'.
lth_CFields-LOGICAL_KEY = '0001'.
lth_CFields-FIELDNAME = 'EXP_REVENUE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'BUDGET_BP'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'CURRENCY'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'CURRENCY_ISO'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'STARTDATE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'EXPECT_END'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'CURR_PHASE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'PHASE_SINCE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'PROBABILITY'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'FORECAST_REL'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SOURCE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'IMPORTANCE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALESCYCLE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'ADDRESS_NO'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'TYPE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'STATUS_SINCE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'DESCRIPTION_OPP'.
APPEND lth_CFields.
*-- Try these to get partners. ???
lth_CFields-FIELDNAME = 'PARTNER_NUMBER'.
APPEND lth_CFields.
*---------[ Organisation ]---------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'ORGMAN'.
lth_CFields-REF_KIND = 'A'.
lth_CFields-LOGICAL_KEY = '0001'. "'0006'.
lth_CFields-FIELDNAME = 'DIS_CHANNEL'.
lth_CFields-CHANGEABLE = ' '. "X = ???
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'DIS_CHANNEL_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'DIVISION'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'DIVISION_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_GROUP'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_GROUP_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_GROUP_SHORT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_OFFICE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_OFFICE_SHORT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_OFF_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORG'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORGR_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORG_ORI'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORG_RESP'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORG_RESP_SHORT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SALES_ORG_SHORT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SERVICE_ORG_RESP'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'SERVICE_ORG'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'DISTRICT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'MODE'.
APPEND lth_CFields.
*---------[ Partner info ]---------
DATA:L_PRHandle LIKE BAPIBUS20001_PARTNER_INS-REF_HANDLE VALUE 1,
L_PRPHandle LIKE BAPIBUS20001_PARTNER_INS-REF_PARTNER_HANDLE VALUE 1.
LOOP AT ith_GetPARTNER.
*-- Create one new partner rec for the BAPI.
MOVE-CORRESPONDING ith_GetPARTNER TO lth_CPartner.
CLEAR lth_CPartner-REF_GUID. "<== No effect either way.
CLEAR lth_CPartner-REF_HANDLE.
CLEAR lth_CPartner-REF_PARTNER_HANDLE.
CLEAR lth_CPartner-REF_PARTNER_FCT.
CLEAR lth_CPartner-REF_PARTNER_NO.
CLEAR lth_CPartner-REF_NO_TYPE.
CLEAR lth_CPartner-REF_DISPLAY_TYPE.
CLEAR lth_CPartner-MAINPARTNER.
CLEAR lth_CPartner-RELATION_PARTNER.
CLEAR lth_CPartner-BUSINESSPARTNERGUID.
lth_CPartner-MAINPARTNER = 'X'.
lth_CPartner-REF_GUID = g_BlankGuid.
lth_CPartner-REF_HANDLE = L_PRHandle.
lth_CPartner-REF_PARTNER_HANDLE = L_PRPHandle.
APPEND lth_CPartner.
*-- Create block of new input_fields for this partner.
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'PARTNER'.
lth_CFields-REF_KIND = 'A'.
lth_CFields-LOGICAL_KEY = L_PRPHandle. "ie: '0001'.
lth_CFields-FIELDNAME = 'DISPLAY_TYPE'.
lth_CFields-CHANGEABLE = ' '.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'KIND_OF_ENTRY'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'NO_TYPE'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'PARTNER_FCT'.
APPEND lth_CFields.
lth_CFields-FIELDNAME = 'PARTNER_NO'.
APPEND lth_CFields.
*-- Inc ref-handles.
L_PRHandle = L_PRHandle + 1. "<== Do NOT increment. (Unless creating multiple opps)
L_PRPHandle = L_PRPHandle + 1. "<== Import to link partners to CFields.
ENDLOOP.
*---------[ Pricing Rec]---------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'PRICING'.
lth_CFields-REF_KIND = 'A'. "A <== No effect setting to A or leave blank.
lth_CFields-LOGICAL_KEY = '0001'.
lth_CFields-FIELDNAME = 'CURRENCY'.
APPEND lth_CFields.
*-------[ CustomerHead Rec]-------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1. "<== Must be set if the others are too.
lth_CFields-REF_GUID = g_BlankGuid.
lth_CFields-OBJECTNAME = 'CUSTOMER_H'.
lth_CFields-REF_KIND = 'A'. "A <== No effect setting to A or leave blank.
lth_CFields-LOGICAL_KEY = '0001'.
*-- Get all custom fields.
DATA: LTH_FieldTab TYPE TABLE OF DFIES WITH HEADER LINE.
CALL FUNCTION 'GET_FIELDTAB_REMOTE'
EXPORTING
TABNAME = 'CRMD_CUSTOMER_H'
TABLES
FIELDTAB = LTH_FieldTab.
*-- Add only custom fields to input-fields list.
LOOP AT LTH_FieldTab FROM 5.
lth_CFields-FIELDNAME = LTH_FieldTab-FieldName.
APPEND lth_CFields.
ENDLOOP.
ENDFORM.
*******************[ END L_BldCFields() ]*******************
********************[ START L_LinkOpp() ]*******************
FORM L_LinkOpp USING p_Mode p_CRMKey p_LinkKey CHANGING p_Ok.
*-- Local vars.
DATA: L_MastGuid TYPE CRMT_OBJECT_GUID,
L_LinkGuid TYPE CRMT_OBJECT_GUID,
L_CheckOk(1) TYPE C VALUE YES,
L_TryAgain(1) TYPE C VALUE NO.
*-- Default this.
p_OK = YES.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-- Get GUID for Master-Opportunity.
PERFORM L_GetGUID USING p_CRMKey CHANGING L_MastGuid p_Ok.
CHECK p_Ok = YES.
*-- Get GUID for Sub-Opportunity.
PERFORM L_GetGUID USING p_LinkKey CHANGING L_LinkGuid p_Ok.
CHECK p_Ok = YES.
*---------[ Build BAPI Table Params ]-----------
DATA: lth_CHeader TYPE TABLE OF BAPIBUS20001_HEADER_UPD WITH HEADER LINE,
lth_CDFlow TYPE TABLE OF BAPIBUS20001_DOC_FLOW_INS WITH HEADER LINE,
lth_CFields TYPE TABLE OF BAPIBUS20001_INPUT_FIELDS WITH HEADER LINE.
*--------------[ HEAD INFO ]------------
READ TABLE ith_GetHEADER INDEX 1. "<== Header info from Master.
MOVE-CORRESPONDING ith_GetHEADER TO lth_CHeader.
APPEND lth_CHeader.
*--------------[ INPUT FIELDS ]------------
CLEAR lth_CFields.
lth_CFields-REF_HANDLE = 1.
lth_CFields-REF_GUID = l_MastGuid. "Master Opp.
lth_CFields-REF_KIND = 'A'.
lth_CFields-OBJECTNAME = 'DOC_FLOW'.
lth_CFields-LOGICAL_KEY = 'INS'. "<== Default to ADD.
*-- Delete (UnLink) works in conjunction with
* lth_CDFlow-BREL_MODE = 'D' set below.
IF p_Mode = 'ULKSOP'.
lth_CFields-LOGICAL_KEY = 'DEL'.
ENDIF.
APPEND lth_CFields.
*-------------[ DOCUMENT FLOW ]------------
*-- Maybe start with original doc-flow data from Master?
READ TABLE ith_GetDOCFLOW INDEX 1.
MOVE-CORRESPONDING ith_GetDOCFLOW TO lth_CDFlow.
lth_CDFlow-REF_GUID = l_MastGuid. "Master Opp.
lth_CDFlow-REF_HANDLE = '1'.
lth_CDFlow-REF_KIND = 'A'.
lth_CDFlow-OBJKEY_A = l_MastGuid. "Master Opp.
lth_CDFlow-OBJTYPE_A = 'BUS2000111'.
lth_CDFlow-LOGSYS_A
lth_CDFlow-OBJKEY_B = l_LinkGuid. "Sub Opp.
lth_CDFlow-OBJTYPE_B = 'BUS2000111'.
lth_CDFlow-LOGSYS_B
lth_CDFlow-RELTYPE = 'MASU'.
lth_CDFlow-VONA_KIND
lth_CDFlow-BREL_KIND = 'A'.
lth_CDFlow-BREL_MODE = 'A'. "A=add, B or C=Change ?, D=Del
*-- Delete (UnLink) works in conjunction with
* lth_CFields-LOGICAL_KEY = 'DEL' set above.
IF p_Mode = 'ULKSOP'.
lth_CDFlow-BREL_MODE = 'D'.
ENDIF.
lth_CDFlow-HANDLE_A
lth_CDFlow-HANDLE_B
CLEAR lth_CDFlow-RELATIONID. "<== Was preventing me from linking multi...
lth_CDFlow-RELATION_HANDLE = 1.
APPEND lth_CDFlow.
*-- Activate trace/debug?
IF S_Break = YES. BREAK-POINT. ENDIF.
*-- If user has Master GUID open in EDIT mode, the
* BAPI will fail to LINK the new sub-opp.
DO.
*-- Clear these every try.
CLEAR ith_ChgReturn. REFRESH ith_ChgReturn.
*---------[ CHANGE/LINK OPPORTUNITY ]--------
CALL FUNCTION 'BAPI_OPPORTUNITY_CHANGEMULTI'
EXPORTING
TESTRUN = ' '
TABLES
HEADER = lth_CHeader
ITEM =
OPPORTUNITY =
ORGANISATION =
PRICING =
PARTNER =
TEXT =
PRODUCT =
STATUS =
SERVICE_OS =
INPUT_FIELDS = lth_CFields
RETURN = ith_ChgReturn
APPOINTMENT =
SCHEDULELINE =
DOCUMENT_FLOW = lth_CDFlow.
PRICING_ITEM =
CONDITION_CREATE =
CONDITION_CHANGE =
CONDITION_DELETE =.
*-- Changes will not appear until you commit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
-
Just ran in to an interesting situation... I have previously implemented the inbound posting of an EVMSTA Idoc that creates an event in SAP EM. Now I want to do it again in SAP EM 5.1 on ECC 6.0 but the inbound process code to post the event is not there and neither is a BAPI implementation. What happened to it?
Hi Kevin,
the settings got somehow lost as the EM component was changed with 5.1. You can refer to the old settings as there was no change until the problem is solved.
Best regards,
Steffen -
Need authoritative (SAP?) answer on BADI breakpoints in update debugging
I'm doing a very simple BADI implementation of:
IF_EX_INSPECTIONLOT_UPDATE~CREATE_IN_UPDATE
called from FM QPBU_LOT_INSERT in QPBU.
Everything is working fine, but here's the problem
QPBU_LOT_INSERT is being called from an update task inside MIGO (the update task for a goods receipt posting.)
When I was doing a customer exit in MIGO, I had to turn on an update debugging session to see a breakpoint in my exit code - the debugger would not go directly to the hard breakpoint in my exit code.
So I assume this is the same for implementations of BADI methods - the regular debugger will NOT go directly to a breakpoint inside the custom implementation of the interface method - you have to turn on update debugging and wait for your method code to appear.
Is this true or not?
If it is, then this seems to me something that would be easy to fix.
After all, if we can have external debugging in WDA, why can't the ABAP debugger be fixed to see a hard breakpoint even if the breakpoint is in customer code that is part of a BADI implememntation method ??????
Thanks for whatever authoritative answer anyone can provide.
djhhi David,
As you said, normal debugging will not always be possible with BAdIs. i dont know about activating update debugging, but there is a way to go to debugger while the BAdI gets executed. Please follow the steps mentioned below:
step1: Goto sE19 and enter the BAPI implementation name->display
step2: choose the interface tab->double click on the method which
is under consideration
step3: code as below
data lv_flag.
while flag is initial.
endwhile.
step4: Now activate the BAdI and execute the transaction, and do the necessary actions(save/delete etc)
step5: goto transaction sm50->you can see your program there
step6: select your program from the list->choose PROGRAM/SESSION from the
menu->Select PROGRAM->DEBUGGING
you are now in the debugger with the BAdI.
<b>
This is an infinite loop inside the BAdI; You should take this out, and re-activate the BAdI, once you are done with the debugging</b>
Hope this helps,
Sajan Joseph.
Maybe you are looking for
-
my ipod is stuck on the 'connect to itunes' screen how do you get it on to the home menu?
-
I am purchasing new 13in MacBook Pro.. Need info on Video editing
I am Purchasing a new MacBook Pro 13 2.5 Dual Core i5 with 8GB of Ram. My work is buying this so I get what I am getting. I will be uploading Sporting events and editing them into 2 to 3 minute Highlight Videos. Should I use Imovie or Final cut Pr
-
How to add button to view maintenance.
Hi, I have a table view maintenance (accessing by sm30) an I need to add "Filter Button" and other buttons if is possible. How can I do this?? Thanks.
-
Originally registered apple ID of the mail can not unlock the iPhone, how to do?
Yesterday a very strange thing happened, suddenly my apple id password error has been unable to log messages, but then I reset my password has been unable to receive my reset password notification letters, then I use the same mail account actually re
-
What settings do I change so I don't have to login every time I boot?
I just got a new imac and whenever I reboot, I am being prompted to enter my password. I've never had this with any of my other macs. How do I turn this setting off? I just want to boot or reboot and not have to login. Thanks,