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
Similar Messages
-
BAPI_OPPORTUNITY_CREATEMULTI : Logical Key in INPUT_FIELDS
Hi All,
I am trying to create oppurtunity using BAPI_OPPORTUNITY_CREATEMULTI . I need to populate the product details . I need to know what is this <b>Logical Key</b> in <b>INPUT_FIELDS</b> structure? What will be the value of Logical Key for Product? Can somebody help me on this.
Thanks in Advance.Pratik,
Thanks for your reply.
Can you give me a sample code for both <b>PRODUCT</b> and <b>INPUT_FIELDS</b> parameters. I tried giving product guid but, it does not seem to work. -
BAPI BAPI_OPPORTUNITY_CREATEMULTI - Problem with Quantity and Unit
Hi,
I have the requirement for creating multiple line items in Oppurtunity with BAPI BAPI_OPPORTUNITY_CREATEMULTI, I am able to create multiple line items in product tab in Oppurtunity.
But now those line items are stored Without Quantity and Units.
I have passed units in product table at fields : volume_unit, process_qty_unit, process_volume_unit_iso.
I have passed quantity in product table at fields : process_qty_unit, process_qty_num, process_qty_den.
Same quantity is also passed at schedule line item field : quantity
Can any1 please suggest?
I tried with all combinations of above possible fields.
I am not sure If i have mistaken in Input fields being passed to this bapi?
Thanks in advance.
Regards,
Narendra.Quantity is maintained under scheduling, so you must include in 'CRM_ORDER_MAINTAIN' under exporting parameters also...
EXPORTING
it_schedlin_i = lt_schedlin_i
Coding for lt_schedlin_i is...
ls_schedlin_i-ref_handle = "counter".
ls_crmt_schedlin_extd-quantity = "quantity".
INSERT ls_crmt_schedlin_extd INTO TABLE ls_schedlin_i-
Coding for input fields is...
ls_input_field-ref_handle = "counter".
ls_input_field-ref_kind = 'B'.
ls_input_field-objectname = 'SCHEDLIN'.
ls_input_names-fieldname = 'QUANTITY'.
INSERT ls_input_names INTO TABLE ls_input_field-field_names.
INSERT ls_input_field INTO TABLE lt_input_field.
Regards. -
BAPI_OPPORTUNITY_CREATEMULTI - Problem with Quantity and Unit
Hi,
I have the requirement for creating multiple line items in Oppurtunity with BAPI BAPI_OPPORTUNITY_CREATEMULTI, I am able to create multiple line items in product tab in Oppurtunity.
But now those line items are stored Without Quantity and Units.
I have passed units in product table at fields : volume_unit, process_qty_unit, process_volume_unit_iso.
I have passed quantity in product table at fields : process_qty_unit, process_qty_num, process_qty_den.
Same quantity is also passed at schedule line item field : quantity
Can any1 please suggest?
I tried with all combinations of above possible fields.
I am not sure If i have mistaken in Input fields being passed to this bapi?
Thanks in advance.
Regards,
Narendra.Hi,
After days, I am however able to get Unit for every Opportunity Item.
stil Quantity is getting not updated.
Has any1 written code for adding Line items into Opportunity using CRM_ORDER_MAINTAIN.
Kindly suggest if any1 has idea or has done the same.
Regards,
Narendra. -
BAPI_OPPORTUNITY_CREATEMULTI Products
I am trying to create an opportunity using BAPI_OPPORTUNITY_CREATEMULTI.
I have successfully created the header info, however I am struggling with the product details. If anyone has any sample code they would care to contribute to the cause, it would be truely appreciated.
I can't get the product or product details to come in with the header details, any suggestions.
Thanks
TC
Edited by: tooCann on Apr 8, 2008 5:08 PMhi
here is the code
HEADER DATA----
it_header-guid = ''.
it_header-handle = gc_handle_1. 'Identification of this opportunity
--ITEM DATA--
it_item-mode = 'A'.
it_item-ordered_prod = int_tab-produkt.
it_item-itm_type = 'ZOPT'.
it_item-handle = gc_handle_2. 'Identification of this item
it_item-header_handle = gc_handle_1. 'Refers to the opportunity for which this item is for.
APPEND it_item.
it_input_fields-ref_handle = gc_handle_2. 'Refers to the item for which this information is for
it_input_fields-objectname = 'ORDERADM_I'.
it_input_fields-ref_kind = 'B'.
it_input_fields-fieldname = 'ORDERED_PROD'.
APPEND it_input_fields.
it_input_fields-fieldname = 'ITM_TYPE'.
APPEND it_input_fields.
Hope this helps!
Here's the form-routine!
(sorry but the remarks are in danish
Notice - there are fields you don't have in you CRM-system (repairs) - just remove these.
FORM opdater .
SORT int_tab BY kundeemne kontpers.
READ TABLE int_tab INDEX 1.
Hvis der ikke er data i int_tab s� stop!
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT int_tab. " INTO wa_info.
CLEAR retur.
REFRESH retur.
-----HEADER DATA--
it_header-guid = ''.
it_header-handle = gc_handle_1.
CONCATENATE 'Konv: ' int_tab-betegnelse INTO
it_header-description SEPARATED BY space.
it_header-process_type = 'ZOPP'.
it_header-descr_language = 'K'.
it_header-langu_iso = 'DA'.
it_header-posting_date = sy-datum.
APPEND it_header.
it_input_fields-ref_handle = gc_handle_1..
it_input_fields-objectname = 'ORDERADM_H'.
it_input_fields-ref_kind = 'A'.
it_input_fields-fieldname = 'PROCESS_TYPE'.
APPEND it_input_fields.
it_input_fields-fieldname = 'OBJECT_ID'.
APPEND it_input_fields.
it_input_fields-fieldname = 'DESCRIPTION'.
APPEND it_input_fields.
--PARTNER DATA--
it_partner-ref_handle = gc_handle_1.
it_partner-display_type = 'BP'.
it_partner-no_type = 'BP'.
it_partner-ref_kind = 'A'.
it_partner-ref_partner_handle = '0000'.
it_partner-partner_no = int_tab-kundeemne.
it_partner-partner_fct = '00000021'.
it_partner-mainpartner = 'X'.
APPEND it_partner.
it_partner-mainpartner = ''.
it_partner-partner_no = int_tab-kontpers.
it_partner-partner_fct = '00000015'.
APPEND it_partner.
it_partner-partner_no = int_tab-amedarb.
it_partner-partner_fct = 'Z0000014'.
APPEND it_partner.
it_input_fields-objectname = 'PARTNER'.
it_input_fields-logical_key = '0000'.
it_input_fields-fieldname = 'PARTNER_FCT'.
APPEND it_input_fields.
it_input_fields-fieldname = 'PARTNER_NO'.
APPEND it_input_fields.
it_input_fields-fieldname = 'DISPLAY_TYPE'.
APPEND it_input_fields.
it_input_fields-fieldname = 'NO_TYPE'.
APPEND it_input_fields.
it_input_fields-fieldname = 'KIND_OF_ENTRY'.
APPEND it_input_fields.
it_input_fields-fieldname = 'MAINPARTNER'.
APPEND it_input_fields.
--OPPORTUNITY DATA--
it_opportunity-ref_handle = gc_handle_1.
it_opportunity-startdate = int_tab-start.
it_opportunity-expect_end = int_tab-****.
it_opportunity-probability = int_tab-succes.
it_opportunity-curr_phase = int_tab-aktfas.
it_opportunity-forecast_rel = int_tab-relpro.
it_opportunity-type = int_tab-smgrp.
it_opportunity-importance = int_tab-priori.
APPEND it_opportunity.
it_input_fields-objectname = 'OPPORT_H'.
it_input_fields-fieldname = 'STARTDATE'.
APPEND it_input_fields.
it_input_fields-fi
in this predefined fields are as follows:
gc_handle_1 TYPE crmt_handle VALUE '0000000001',
gc_handle_2 TYPE crmt_handle VALUE '0000000002'.
further explaination :
gc_handle_1 is used for an item to bind it to a opportunity and gc_handle_2 is used to bind the information for an item to an item.
You can actually create several opportunities with one call to the BAPI!
In my code I only create one per call!
guess it will help you
best regards
ashish -
BAPI_OPPORTUNITY_CREATEMULTI - Partners problem
Hello
I am struggling with creation of opportunity with BAPI_OPPORTUNITY_CREATEMULTI.
Can anyone give working example of implementation using input fields, header, opportunity and partner structures?
I cannot create opp where partners would be filled.
Regards
Radekok thank you, I used crmd_order_maintain to get right values.
eg. structures for partner:
ls_partner-ref_guid = ls_header-guid.
ls_partner-ref_handle = '0000000001'.
ls_partner-ref_kind = 'A'.
ls_partner-ref_partner_handle = '0001'.
ls_partner-partner_no = '0003000018'. "-> leading zeros
ls_partner-partner_fct = '00000021'.
ls_partner-no_type = 'BP'.
ls_partner-display_type = 'BP'.
ls_partner-KIND_OF_ENTRY = 'C'.
APPEND ls_partner to lt_partner.
and for input fields:
ls_input-REF_HANDLE = '0000000001'.
ls_input-REF_GUID = ls_header-guid.
ls_input-REF_KIND = 'A'.
ls_input-OBJECTNAME = 'PARTNER'.
ls_input-LOGICAL_KEY = '0001'.
ls_input-FIELDNAME = 'PARTNER_NO'.
APPEND ls_input to lt_input.
ls_input-FIELDNAME = 'PARTNER_FCT'.
APPEND ls_input to lt_input.
ls_input-FIELDNAME = 'NO_TYPE'.
APPEND ls_input to lt_input.
ls_input-FIELDNAME = 'DISPLAY_TYPE'.
APPEND ls_input to lt_input.
ls_input-FIELDNAME = 'KIND_OF_ENTRY'.
APPEND ls_input to lt_input.
clear ls_input.
Regards -
BAPI_OPPORTUNITY_CREATEMULTI Appointment
Anyone have any experience with BAPI_OPPORTUNITY_CREATEMULTI
creating APPOINTMENTS?
Any code would be appreciated.
In LCRM_BUSPROCESSND_BAPIF66, there is a call to map_into_appointment, which in our case does not return a Time zone... and cause a problemHi,
I am not able to upload the data for Partner and Sales Prospect fields using BAPI_OPPORTUNITY_CREATEMULTI whereas all the other header and item fields are getting uploaded. Kindly suggest solution for this issue.
Regards,
Dinesh -
Populating Quantity field in BAPI : "BAPI_OPPORTUNITY_CREATEMULTI"
I want to populate quantity field for an Item while creating Opportunity using BAPI_OPPORTUNITY_CREATEMULTI.
along with other data, I am populating BAPI internal table required for quantity as below, opportunity is being created with item. But quantity field is blank. Can anyone advise what I have been doing wrong or whats right way of populating this table parameter.
Appreciate help on this.
s_scheduleline-item_handle = 0000000002.
s_scheduleline-handle = 0000000001.
s_scheduleline-quantity = s_valid-est_qty. " Quantity
APPEND s_scheduleline TO it_scheduleline.
s_input-ref_handle = 0000000002
s_input-ref_kind = 'B'.
s_input-objectname = 'SCHEDLIN'.
s_input-fieldname = 'QUANTITY'.
APPEND s_input TO it_input.
CALL FUNCTION 'BAPI_OPPORTUNITY_CREATEMULTI'
TABLES
header = it_header
opportunity = it_opp
partner = it_partner
appointment = it_appointment
status = it_status
customer_head = it_cust_h
text = it_text
item = it_item
product = it_product
scheduleline = it_scheduleline
pricing_item = it_price_i
input_fields = it_input
saved_process = it_saved
return = it_return.Be sure to reset logical_key field from input_fields structure after inserting partner data.
ls_fields-objectname = 'PARTNER'.
ls_fields-logical_key = '0000'.
ls_fields-fieldname = gc_fieldname-partner_no.
APPEND ls_fields TO lt_fields.
ls_fields-logical_key = ''.
Edited by: Dalibor Riger on Nov 29, 2011 5:09 PM -
Creation of Opportunity using standard BAPI
Hello,
I am using BAPI_OPPORTUNITY_CREATEMULTI for creating opportunity. It is generating GUID and Oject ID. But the data is not storing in data base table except GUID in CRMD_OPPORT_H table. And even it is not displaying all the data which is i am passing through flat file in t-code : 'CRMD_ORDER' .Hello Nizam,
I am also working on the same requirement.
I am able to create the Opportunity successful through the BAPI "BAPI_OPPORTUNITY_CREATEMULTI".
and it is also updating all the required fields.
But issue which i am facing is, I am able to see the opportunity in the GUI but not in the WEB UI.
Could you please help me on this?
Which parameter I need to set in order to Pass the opportunity on the WEB UI.
I would really appriciate if you share the code.
Thanks & Regards
Sachin -
Problem in item data updation in Opportunity Creation
Hi All,
I am able to create the opportunity with BAPI_OPPORTUNITY_CREATEMULTI but the item data ( product tab in the opportunity ) is blank.
Please see the code below which i am using for this item data population. Update is getting terminated if i am using header handle. Please send me the correct solution for this problem.
*set item data
clear ls_input_field.
ls_input_field-ref_handle = lc_handle_2.
ls_input_field-ref_kind = 'B'.
ls_input_field-objectname = 'ORDERADM_I'.
ls_input_field-fieldname = 'HANDLE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'HEADER_HANDLE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'LOGICAL_KEY'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'ORDERED_PROD'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'NUMBER_INT'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'MODE'.
INSERT ls_input_field INTO TABLE lt_input_field.
lv_item = 0.
lv_number_int = 0.
ls_item-handle = lc_handle_2.
ls_item-header_handle = lc_handle_1.
ls_item-parent_handle = lc_handle_1.
if i_form_id = 'CAP'.
ls_item-ordered_prod = 'CAP_FEE'.
ls_item-number_int = lv_number_int + 10.
ls_item-mode = 'A'.
append ls_item to lt_item.
lv_number_int = ls_item-number_int.
clear ls_item.
*set schedule line
clear ls_input_field.
ls_input_field-ref_handle = lc_handle_2.
ls_input_field-objectname = 'SCHEDLIN'.
ls_input_field-ref_kind = 'B'.
ls_input_field-fieldname = 'ITEM_HANDLE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'HANDLE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'QUANTITY'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_scheduleline-item_handle = lc_handle_2.
ls_scheduleline-handle = lc_handle_1.
ls_scheduleline-quantity = 1.
append ls_scheduleline to lt_scheduleline.
endif.
- PrakashHi,
Use the below code to maintain line items, in FM 'CRM_ORDER_MAINTAIN'.
CREATION OF THE ITEM GUID
CLEAR v_item_ref_guid.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = v_item_ref_guid.
CREATION OF SCHEDULING LOGICAL GUID.
CLEAR v_sched_logical.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = v_sched_logical.
values for it_pricing
CLEAR wa_pricing.
CLEAR it_pricing.
wa_pricing-ref_handle = c_ref_handle2.
wa_pricing-ref_guid = v_item_ref_guid.
wa_pricing-ref_kind = c_b_kind.
INSERT wa_pricing INTO TABLE it_pricing.
values for product_i-UOM
CLEAR wa_product.
CLEAR wa_fieldname.
CLEAR it_fields.
wa_fieldname-fieldname = c_process_qty_unit_field.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_input_field.
wa_input_field-ref_handle = c_ref_handle2.
wa_input_field-ref_guid = v_item_ref_guid.
wa_input_field-ref_kind = c_b_kind.
wa_input_field-objectname = c_product_i_input.
wa_input_field-field_names = it_fields.
INSERT wa_input_field INTO TABLE it_input_field.
CLEAR wa_product_i.
wa_product_i-ref_guid = v_item_ref_guid.
wa_product_i-ref_handle = c_ref_handle2.
wa_product_i-process_qty_unit = wa_product-process_qty_unit.
INSERT wa_product_i INTO TABLE it_product_i.
ENDIF.
values for service_i
CLEAR wa_input_field.
wa_input_field-ref_handle = c_ref_handle2.
wa_input_field-ref_guid = v_item_ref_guid.
wa_input_field-ref_kind = c_b_kind.
wa_input_field-objectname = c_service_i.
wa_input_field-field_names = it_fields.
INSERT wa_input_field INTO TABLE it_input_field.
CLEAR wa_service_i.
wa_service_i-ref_guid = v_item_ref_guid.
wa_service_i-ref_handle = c_ref_handle2.
INSERT wa_service_i INTO TABLE it_service_i.
fieldnames for quantity
CLEAR wa_schedul.
READ TABLE it_schedul INTO wa_schedul INDEX 1.
IF sy-subrc = 0.
CLEAR wa_fieldname.
CLEAR it_fields.
wa_fieldname-fieldname = c_logical_key.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_fieldname.
wa_fieldname-fieldname = c_quantity.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_input_field.
wa_input_field-ref_handle = c_ref_handle2.
wa_input_field-ref_guid = v_item_ref_guid.
wa_input_field-ref_kind = c_b_kind.
wa_input_field-objectname = c_schedlin_input.
wa_input_field-logical_key = c_log_key_item.
wa_input_field-field_names = it_fields.
INSERT wa_input_field INTO TABLE it_input_field.
CLEAR wa_quantity.
CLEAR it_quantity.
wa_quantity-guid = v_sched_logical.
wa_quantity-item_guid = v_item_ref_guid.
wa_quantity-quantity = wa_schedul-quantity.
wa_quantity-logical_key = c_log_key_item.
wa_quantity-handle = c_ref_handle0.
INSERT wa_quantity INTO TABLE it_quantity.
valus for quantity
CLEAR wa_schedulin.
wa_schedulin-ref_guid = v_item_ref_guid.
wa_schedulin-ref_handle = c_ref_handle2.
wa_schedulin-schedlines = it_quantity.
INSERT wa_schedulin INTO TABLE it_schedulin.
ENDIF.
fieldnames for product
CLEAR wa_orderadm.
READ TABLE it_orderadm INTO wa_orderadm INDEX 1.
IF sy-subrc = 0.
CLEAR wa_fieldname.
CLEAR it_fields.
wa_fieldname-fieldname = c_itm_proc_ident.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_fieldname.
wa_fieldname-fieldname = c_mode_input.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_fieldname.
wa_fieldname-fieldname = c_ordered_prod.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_fieldname.
wa_fieldname-fieldname = c_number_int.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_fieldname.
wa_fieldname-fieldname = c_prog_id.
INSERT wa_fieldname INTO TABLE it_fields.
CLEAR wa_input_field.
wa_input_field-ref_handle = c_ref_handle2.
wa_input_field-ref_guid = v_item_ref_guid.
wa_input_field-objectname = c_orderadm_i_input.
wa_input_field-field_names = it_fields.
INSERT wa_input_field INTO TABLE it_input_field.
values for product
CLEAR wa_orderprp_i.
CLEAR v_itemno.
v_itemno = v_itemno + v_line_incr.
wa_orderprp_i-guid = v_item_ref_guid.
wa_orderprp_i-header = v_head_ref_guid.
wa_orderprp_i-number_int = v_itemno.
wa_orderprp_i-ordered_prod = wa_orderadm-ordered_prod.
wa_orderprp_i-description = wa_orderadm-description.
wa_orderprp_i-handle = c_ref_handle2.
wa_orderprp_i-number_int = wa_orderadm-number_int .
wa_orderprp_i-zzprogram_id = wa_orderadm-zzprogram_id.
INSERT wa_orderprp_i INTO TABLE it_orderprp_i.
ENDIF -
How to improve the performance of the Data Migration program ?
Hi All,
I have written a program for Data Migration of Opportunities, but it is taking a lot of time to create or update opportunities.
I have used so many function modules like
" 'CONVERSION_EXIT_ALPHA_INPUT' " -- 8 TIMES
"GUID_CREATE'" -- 4 TIMES
"CRM_ORDER_READ" -- 1 TIME
"CONVERT_INTO_TIMESTAMP" -- 4 TIMES
"CRM_ORDER_MAINTAIN" --- 1 TIME
"CRM_ORDERADM_H_CHANGE_OW" - 1 TIME
"'BAPI_BUSPROCESSND_SAVE" -- 1 TIME
"BAPI_TRANSACTION_COMMIT" -- 1 TIME
"BAPI_BUSPROCESSND_CREATEMULTI" OR "BAPI_BUSPROCESSND_CHANGEMULTI"
and all these function modules are for every record in a loop. for 1000 records it is taking 75 min approximately. How i can improve its performance ?Hi Raman,
For Performance improvment do the following things:
First Remove the CRM_ORDER_READ and use the tables to get the data and then use Read Statement on Internal Tables.
Second, Instead of BAPI_BUSPROCESSND_CREATEMULTI use BAPI_OPPORTUNITY_CREATEMULTI and then use BAPI_TRANSACTION_COMMIT. No need to use 'BAPI_BUSPROCESSND_SAVE.
Third thing, Not sure why you are creating guid 4 times, No need to generate guid if you use BAPI_OPPORTUNITY_CREATEMULTI. Guid will get generated.
Fourth, instead of using 'CONVERSION_EXIT_ALPHA_INPUT' multiple times, create a variable of req. length and then pass the values.
Hope this helps. -
BADI or User Exit for Txn : CRMD_ORDER
Hi Experts,
Is there any badi or user-exits for the transaction crmd_order.
regrads,
arul jtohi aDear Arul Jothi,
BAPI_ACTIVITYCRM_CREATEMULTI
BAPI_BUSPROCESSND_CREATEMULTI
CRM_BUSPROCESSND_BAPI
CRM_LEADCRM_BAPI
BAPI_LEAD_CREATEMULTI
CRM_OPPORTUNITYCRM_BAPI
BAPI_OPPORTUNITY_CREATEMULTI
CRM_SLSTRANSACTCRM_BAPI
BAPI_SLSTRANSACT_CREATEMULTI
Also, visit the following thread:
Change status for sales order in crmd_order
BAdi/Enhancement:
/people/alwin.vandeput2/blog/2006/04/13/how-to-search-for-badis-trace-it
Regards,
Naveen. -
Object id for opportunity is created through se38 but that object id doesnt exist in sap crm webui
Hello All,,
i am creating an opportunity from report program (se38) using fm bapi_opportunity_createmulti.
object id is created successfully without any error .
but that object id does not exist when i am giving that object id to sap crm .
please help me out what i am missing or what happen.
Ahmad....Thanks Arden now its creating i left logical keys and handle in my FM modules.
but i am getting eroor which i have attch please tell me how can i do this . -
Hi All,
I would like to create an opportunity with all the relavent fields using Function Modules. Can anyone provide me with a Report Program for the creation of an Opportunity.
Thanks in Advance,
Shwetha .Good job Joost Stallaert.........
A simple program using BAPI_OPPORTUNITY_CREATEMULTI .
DATA: ls_header LIKE bapibus20001_header_ins,
lt_header TYPE STANDARD TABLE OF
bapibus20001_header_ins,
ls_opp LIKE bapibus20001_opportunity,
lt_opp TYPE STANDARD TABLE OF
bapibus20001_opportunity,
lt_pricing TYPE STANDARD TABLE OF
bapibus20001_pricing,
ls_pricing TYPE bapibus20001_pricing,
ls_input_fields TYPE bapibus20001_input_fields,
lt_input_fields TYPE STANDARD TABLE OF
bapibus20001_input_fields,
lt_return TYPE STANDARD TABLE OF bapiret2 ,
ls_return TYPE bapiret2 .
DATA ls_saved_process TYPE bapibus20001_object_id.
DATA: lt_guid_16 TYPE crmt_object_guid_tab,
ls_guid_16 TYPE crmt_object_guid.
DATA: lv_langu TYPE sylangu,
lv_uname TYPE syuname,
lt_SAVED_PROCESS type BAPIBUS20001_OBJECT_ID occurs 0 .
CONSTANTS:
pricing TYPE crmt_object_name VALUE 'PRICING',
gc_handle_1 TYPE crmt_handle VALUE '0000000001',
BEGIN OF gc_fieldname,
startdate TYPE crmt_fieldname VALUE 'STARTDATE',
expect_end TYPE crmt_fieldname VALUE 'EXPECT_END',
END OF gc_fieldname,
BEGIN OF gc_object_kind,
orderadm_h TYPE crmt_object_kind VALUE 'A',
orderadm_i TYPE crmt_object_kind VALUE 'B',
END OF gc_object_kind,
BEGIN OF gc_object_name,
opport_h TYPE crmt_object_name VALUE 'OPPORT_H',
order TYPE crmt_object_name VALUE 'ORDER',
orderadm_h TYPE crmt_object_name VALUE 'ORDERADM_H',
orderadm_i TYPE crmt_object_name VALUE 'ORDERADM_I',
END OF gc_object_name.
ref kinds
CONSTANTS: BEGIN OF gc_object_ref_kind,
orderadm_h TYPE crmt_object_kind
VALUE gc_object_kind-orderadm_h,
orderadm_i TYPE crmt_object_kind
VALUE gc_object_kind-orderadm_i,
any TYPE crmt_object_kind
VALUE space,
END OF gc_object_ref_kind.
Admin Header
ls_header-description = 'GV REDDY PRASAD'.
ls_header-handle = '1'.
ls_header-process_type = 'OPPT'.
ls_header-descr_language = sy-langu.
ls_header-langu_iso = sy-langu.
APPEND ls_header TO lt_header.
CLEAR ls_input_fields.
ls_input_fields-ref_handle = '1'.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'ORDERADM_H'.
ls_input_fields-fieldname = 'PROCESS_TYPE'.
APPEND ls_input_fields TO lt_input_fields.
ls_input_fields-fieldname = 'OBJECT_ID'.
APPEND ls_input_fields TO lt_input_fields.
ls_input_fields-fieldname = 'DESCRIPTION'.
APPEND ls_input_fields TO lt_input_fields.
Opportunity Header
ls_input_fields-objectname = 'OPPORT_H'.
ls_opp-ref_handle = '1'.
ls_input_fields-fieldname = 'EXP_REVENUE'.
ls_opp-exp_revenue = '0012'.
APPEND ls_input_fields TO lt_input_fields.
ls_input_fields-fieldname = 'CURRENCY'.
ls_opp-currency = 'INR'.
ls_opp-currency_iso = 'INR'.
APPEND ls_input_fields TO lt_input_fields.
ls_pricing-ref_handle = gc_handle_1.
ls_pricing-ref_kind = gc_object_ref_kind-orderadm_h.
ls_pricing-currency = 'INR'.
APPEND ls_pricing TO lt_pricing.
ls_input_fields-objectname = pricing.
APPEND ls_input_fields TO lt_input_fields.
ls_input_fields-objectname = gc_object_name-opport_h.
ls_input_fields-fieldname = gc_fieldname-startdate.
ls_opp-startdate = sy-datum.
APPEND ls_input_fields TO lt_input_fields.
ls_input_fields-fieldname = gc_fieldname-expect_end.
ls_opp-expect_end = sy-datum.
APPEND ls_input_fields TO lt_input_fields.
CALL FUNCTION 'BAPI_OPPORTUNITY_CREATEMULTI'
TABLES
HEADER = lt_header
OPPORTUNITY = lt_opp
INPUT_FIELDS = lt_input_fields
RETURN = lt_return
SAVED_PROCESS = lt_saved_process .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
******To display the record or error
loop at lt_return into ls_return.
write ls_return-MESSAGE.
endloop.
loop at lt_saved_process into ls_saved_process.
write ls_saved_process-OBJECT_ID.
endloop. -
Error opening an opportunity / transaction
Hi Experts,
I have a trouble when i Want to open a opportunity. I have done a Multi creation of opportunities with the BAPI_OPPORTUNITY_CREATEMULTI
Now when i go to CRMD_ORDER and I try to open one of these opportunities charged, i have the error: "Transaction with the transaction number 'xxxxxxxx' is not available or archived. Message no. CRM_ORDERADM_H012
If i try to open the transaction in UI i have the same error.
Please help us,
Thanks in advance.
Regards.Hi,
In the SAP GUI, the Opportunity is retrieved through the One Order API - CRM_ORDER_READ. So, my guess is that, before the call is made to this Function Module, we have to append the Transaction ID field with a wild card character like *. As the underlying Data Element is a Character field, it will behave in Searching of a Character field. But, we have to check this approach.
I have a couple of doubts. Can you debug the CRM_ORDER_READ Function Module and have a look what exactly is getting filled in the field Transaction ID. As the Web Client UI uses the Search Framework, we can compare the behavior of retrieving the data.
Hope this helps.
Thanks,
Samantak.
Maybe you are looking for
-
How can I mix landscape with portrait pages in InDesign CS3?
I want to put together a very simple four-page document with images and accompanying captions, to be inserted as plates into the middle of a book. Unfortunately, I don't seem to be able to find a way of mixing portrait and landscape images. The first
-
How can I create a scene and move 3D models in INSIGHT with Labview?
Hi! I need some help in doing a LabView application. What i have to do is controlling a 3D model represented in Insight with Labview. Something similar like the six-axis-robot example. I follow the insight configuration wizard, but nothing moves. Com
-
Can SAP R/3 send RFC response to Xi
Hi , I have one scenario where Sap has to trigger an RFC call and shouls send the response to XI and the Xi should write that response to file . How to send just response of RFC to XI ??
-
Read and display the field values in the table control
Hi Experts, I am new to the Table Control. I have created table control using the wizard where i have mentioned the ztable while creating which consist of the following fields. Item Number Material number Material Description Net Price. I would like
-
My camera is in a productivity box, how do I get it out
the camera is now in a productivity box on my iPhone. How do I undo this?