Posted: Sat Apr 26, 2008 6:09 pm Post subject: BAPI_BUPA_CENTRAL_GETDETAIL
BAPI_BUPA_CENTRAL_GETDETAIL - SAP BP, BAPI: Read Central Data
Code:
FUNCTION ZRSAX_BIW_GET_DATA_SIMPLE_02.
*"----------------------------------------------------------------------
""Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZMG_STRUCT_02 OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Example: DataSource for table SFLIGHT
* TABLES: SFLIGHT.
tables: zmg_struct_02 .
* Auxiliary Selection criteria structure
* DATA: L_S_SELECT TYPE SRSC_S_SELECT.
data : ITAB_ZMG type STANDARD TABLE OF zmg_struct_02,
WA_ZMG TYPE zmg_struct_02.
DATA : ITAB_GUID1 TYPE STANDARD TABLE OF BAPIBUS20001_GUID_DIS.
DATA : ITAB_GUID TYPE STANDARD TABLE OF BAPIBUS20001_GUID_DIS,
WA_GUID LIKE LINE OF ITAB_GUID,
ITAB_ACTIVITY TYPE STANDARD TABLE OF BAPIBUS20001_ACTIVITY_DIS,
ITAB_ACTIVITY1 TYPE STANDARD TABLE OF BAPIBUS20001_ACTIVITY_DIS,
WA_ACTIVITY LIKE LINE OF ITAB_ACTIVITY,
WA_ACTIVITY1 LIKE LINE OF ITAB_ACTIVITY1,
ITAB_PRODUCT TYPE STANDARD TABLE OF BAPIBUS20001_PRODUCT_DIS,
ITAB_PRODUCT1 TYPE STANDARD TABLE OF BAPIBUS20001_PRODUCT_DIS,
WA_PRODUCT LIKE LINE OF ITAB_PRODUCT,
WA_PRODUCT1 LIKE LINE OF ITAB_PRODUCT1,
WA_GUID1 LIKE LINE OF ITAB_GUID1.
DATA : LV_GUID TYPE CRMT_OBJECT_GUID_TAB.
DATA : ITAB_SCHED TYPE STANDARD TABLE OF BAPIBUS20001_SCHEDLIN_ITEM_DIS.
DATA : ITAB_SCHED1 TYPE STANDARD TABLE OF BAPIBUS20001_SCHEDLIN_ITEM_DIS.
DATA : ITAB_SALES TYPE STANDARD TABLE OF BAPIBUS20001_SALES_DIS.
DATA : ITAB_SALES1 TYPE STANDARD TABLE OF BAPIBUS20001_SALES_DIS.
DATA : WA_SALES LIKE LINE OF ITAB_SALES,
WA_SALES1 LIKE LINE OF ITAB_SALES1.
DATA : ITAB_ORGMAN TYPE STANDARD TABLE OF BAPIBUS20001_ORGMAN_DIS.
DATA : ITAB_ORGMAN1 TYPE STANDARD TABLE OF BAPIBUS20001_ORGMAN_DIS.
DATA : ITAB_PRICING TYPE STANDARD TABLE OF BAPIBUS20001_PRICING_DIS.
DATA : ITAB_PRICING1 TYPE STANDARD TABLE OF BAPIBUS20001_PRICING_ITEM_DIS.
DATA : WA_PRICING LIKE LINE OF ITAB_PRICING,
WA_PRICING1 LIKE LINE OF ITAB_PRICING1.
DATA : ITAB_HEADER TYPE STANDARD TABLE OF BAPIBUS20001_HEADER_DIS.
DATA : ITAB_HEADER1 TYPE STANDARD TABLE OF BAPIBUS20001_HEADER_DIS.
DATA : WA_HEADER LIKE LINE OF ITAB_HEADER.
DATA : WA_HEADER1 LIKE LINE OF ITAB_HEADER1.
DATA : ITAB_DOC_FLOW TYPE STANDARD TABLE OF BAPIBUS20001_DOC_FLOW_DIS.
DATA : WA_DOC_FLOW LIKE LINE OF ITAB_DOC_FLOW.
DATA : ITAB_STATUS TYPE STANDARD TABLE OF BAPIBUS20001_STATUS_DIS.
DATA : ITAB_STATUS1 TYPE STANDARD TABLE OF BAPIBUS20001_STATUS_DIS.
DATA : WA_STATUS LIKE LINE OF ITAB_STATUS.
DATA : WA_STATUS1 LIKE LINE OF ITAB_STATUS1.
DATA : ITAB_APPOINTMENT TYPE STANDARD TABLE OF BAPIBUS20001_APPOINTMENT_DIS.
DATA : ITAB_APPOINTMENT1 TYPE STANDARD TABLE OF BAPIBUS20001_APPOINTMENT_DIS.
DATA : ITAB_PARTNER TYPE STANDARD TABLE OF BAPIBUS20001_PARTNER_DIS.
DATA : ITAB_PARTNER1 TYPE STANDARD TABLE OF BAPIBUS20001_PARTNER_DIS.
DATA : WA_PARTNER LIKE LINE OF ITAB_PARTNER.
DATA : WA_PARTNER1 LIKE LINE OF ITAB_PARTNER.
DATA : DATE_TO(2) TYPE C.
DATA : WA_APPOINTMENT LIKE LINE OF ITAB_APPOINTMENT.
DATA : WA_APPOINTMENT1 LIKE LINE OF ITAB_APPOINTMENT1.
DATA : MONTH(3) TYPE C.
DATA : ITAB_ITEM TYPE STANDARD TABLE OF BAPIBUS20001_ITEM_DIS.
DATA : ITAB_ITEM1 TYPE STANDARD TABLE OF BAPIBUS20001_ITEM_DIS.
DATA : WA_ITEM LIKE LINE OF ITAB_ITEM,
WA_ITEM1 LIKE LINE OF ITAB_ITEM1.
DATA : LS_CUSTOMER TYPE CRMD_CUSTOMER_H.
DATA : LV_GUID1 TYPE CRMT_OBJECT_GUID.
DATA : GROSS_VALUE TYPE BAPICUREXT.
DATA : BASE_PRICE TYPE BAPICUREXT.
DATA : DISCOUNT TYPE BAPICUREXT.
DATA : LS_BP LIKE BAPIBUS1006_HEAD-BPARTNER.
DATA : LS_ADDRESSDATA TYPE BAPIBUS1006_ADDRESS.
DATA : ITAB_TEL TYPE STANDARD TABLE OF BAPIADTEL.
DATA : WA_TEL LIKE LINE OF ITAB_TEL.
DATA : ITAB_EXT_REF1 TYPE STANDARD TABLE OF BAPIBUS20001_EXT_REF_DIS.
DATA : WA_EXT_REF1 LIKE LINE OF ITAB_EXT_REF1.
DATA : LS_CENTRALDATAPERSON TYPE BAPIBUS1006_CENTRAL_PERSON.
DATA : WA_SCHED LIKE LINE OF ITAB_SCHED,
WA_SCHED1 LIKE LINE OF ITAB_SCHED1.
DATA : WA_ORGMAN1 LIKE LINE OF ITAB_ORGMAN1.
DATA : ITAB_OPPORT TYPE STANDARD TABLE OF BAPIBUS20001_OPPORTUNITY_DIS.
DATA : WA_OPPORT LIKE LINE OF ITAB_OPPORT.
DATA : LS_CENTRALDATA LIKE BAPIBUS1006_CENTRAL.
DATA : LS_CENTRALDATAORGANIZATION LIKE BAPIBUS1006_CENTRAL_ORGAN.
********DECLARATION OF INTERNAL TABLE**************
TYPES : BEGIN OF GS_FIELDS,
OPPT_ID TYPE CRMT_OBJECT_ID,
DOC_FLOW_GUID TYPE CRMT_DOC_FLOW_ID,
QUOT_DESC TYPE CRMT_PROCESS_DESCRIPTION,
QUOT_CR_DATE TYPE CRMT_CREATED_AT,
OPPT_STATUS TYPE CRM_J_STATUS,
OPPT_CLOSE_DATE TYPE SC_DATETO,
MONTH(3) TYPE C,
QUOT_PRIMARY TYPE CRMT_PARTNER_NO,
QUOT_START_DATE TYPE SC_DATEFRO,
QUOT_UPDATE_BY TYPE CRMT_CREATED_BY,
QUOT_CHANGE_DATE TYPE CRMT_CHANGED_AT,
QUOT_ITEM_LINE_NUMBER TYPE CRMT_ITEM_NO,
OPPT_HEADER_LVL_PROD TYPE CRMT_ORDERED_PROD,
QUOT_PRODUCT TYPE CRMT_ORDERED_PROD,
QUOT_PROD_HIER TYPE CRMT_PROD_HIERARCHY,
QUOT_PROD_DESC TYPE COMT_PRSHTEXTX,
QUOT_PROD_QUAN TYPE CRMT_QTY_ORDER,
QUOT_PROD_UNIT_PRICE TYPE BAPICUREXT,
QUOT_DISCOUNT TYPE BAPICUREXT,
QUOT_GROSS_VALUE TYPE BAPICUREXT,
QUOT_NET_VALUE TYPE BAPICUREXT,
QUOT_CURRENCY TYPE CRMT_TAX_WAERS,
OPPT_ACCT_ID TYPE CRMT_PARTNER_NO,
OPPT_ACCT_NAME(80) TYPE C,
OPPT_ADDRESS1(70) TYPE C,
OPPT_CITY TYPE AD_CITY1,
OPPT_STATE TYPE REGIO,
OPPT_COUNTRY TYPE LAND1,
OPPT_POSTAL_CODE TYPE AD_PSTCD1,
OPPT_PHONE TYPE AD_TLNMBR,
OPPT_CONTACT_PERSON TYPE CRMT_PARTNER_NO,
QUOT_STATUS TYPE CRM_J_STATUS,
QUOT_SALES_ORG TYPE CRMT_REGION,
OPPT_SITE_ID TYPE ZEEW_DATAELEMENT0401,
OPPT_DESC TYPE CRMT_PROCESS_DESCRIPTION,
OPPT_PRIORITY TYPE CRMT_PRIORITY,
OPPT_PRIMARY TYPE CRMT_PARTNER_NO,
OPPT_ST_DATE TYPE SC_DATEFRO,
OPPT_CHAN_BY TYPE CRMT_CHANGED_BY,
OPPT_CHAN_DT TYPE CRMT_CHANGED_AT,
QUOT_EXT_NUM TYPE CRMT_EXT_REF_NUM,
END OF GS_FIELDS.
* TYPES : BEGIN OF WA_FIELDS1,
* OPPT_ID TYPE CRMT_OBJECT_ID,
* DOC_FLOW_GUID TYPE CRMT_DOC_FLOW_ID,
* QUOT_DESC TYPE CRMT_PROCESS_DESCRIPTION,
* QUOT_CR_DATE TYPE CRMT_CREATED_AT,
* OPPT_STATUS TYPE CRM_J_STATUS,
* OPPT_CLOSE_DATE TYPE SC_DATETO,
* MONTH(3) TYPE C,
* QUOT_PRIMARY TYPE CRMT_PARTNER_NO,
* QUOT_START_DATE TYPE SC_DATEFRO,
* QUOT_UPDATE_BY TYPE CRMT_CREATED_BY,
* QUOT_CHANGE_DATE TYPE CRMT_CHANGED_AT,
* QUOT_ITEM_LINE_NUMBER TYPE CRMT_ITEM_NO,
* OPPT_HEADER_LVL_PROD TYPE CRMT_ORDERED_PROD,
* QUOT_PRODUCT TYPE CRMT_ORDERED_PROD,
* QUOT_PROD_HIER TYPE CRMT_PROD_HIERARCHY,
* QUOT_PROD_DESC TYPE COMT_PRSHTEXTX,
* QUOT_PROD_QUAN TYPE CRMT_QTY_ORDER,
* QUOT_PROD_UNIT_PRICE TYPE BAPICUREXT,
* QUOT_DISCOUNT TYPE BAPICUREXT,
* QUOT_GROSS_VALUE TYPE BAPICUREXT,
* QUOT_NET_VALUE TYPE BAPICUREXT,
* QUOT_CURRENCY TYPE CRMT_TAX_WAERS,
* OPPT_ACCT_ID TYPE CRMT_PARTNER_NO,
* OPPT_ACCT_NAME(80) TYPE C,
* OPPT_ADDRESS1(70) TYPE C,
* OPPT_CITY TYPE AD_CITY1,
* OPPT_STATE TYPE REGIO,
* OPPT_COUNTRY TYPE LAND1,
* OPPT_POSTAL_CODE TYPE AD_PSTCD1,
* OPPT_PHONE TYPE AD_TLNMBR,
* OPPT_CONTACT_PERSON TYPE CRMT_PARTNER_NO,
* QUOT_STATUS TYPE CRM_J_STATUS,
* QUOT_SALES_ORG TYPE CRMT_REGION,
* OPPT_SITE_ID TYPE ZEEW_DATAELEMENT0401,
* OPPT_DESC TYPE CRMT_PROCESS_DESCRIPTION,
* OPPT_PRIORITY TYPE CRMT_PRIORITY,
* OPPT_PRIMARY TYPE CRMT_PARTNER_NO,
* OPPT_ST_DATE TYPE SC_DATEFRO,
* OPPT_CHAN_BY TYPE CRMT_CHANGED_BY,
* OPPT_CHAN_DT TYPE CRMT_CHANGED_AT,
* QUOT_EXT_NUM TYPE CRMT_EXT_REF_NUM,
* END OF WA_FIELDS1.
DATA : ITAB_FIELDS TYPE STANDARD TABLE OF GS_FIELDS.
DATA : WA_FIELDS LIKE LINE OF ITAB_FIELDS.
DATA : WA_FIELDS1 LIKE LINE OF ITAB_FIELDS.
DATA : LV_SUBTOTAL1 TYPE BAPICUREXT.
DATA : LV_NETVALUE TYPE BAPICUREXT.
DATA : LV_FIRSTNAME TYPE BU_NAMEP_F.
DATA : LV_LASTNAME TYPE BU_NAMEP_L.
DATA : LV_FULLNAME(80) TYPE C.
DATA : LV_STREET TYPE AD_STREET.
DATA : LV_HOUSE_NO TYPE AD_HSNM1.
DATA : LV_ST_HNO(70) TYPE C.
DATA : LV_BP TYPE BU_PARTNER.
DATA : LV_BP1 TYPE BU_PARTNER.
DATA : ITAB_ORDERADM_H TYPE STANDARD TABLE OF CRMD_ORDERADM_H.
DATA : WA_ORDERADM_H LIKE LINE OF ITAB_ORDERADM_H.
DATA : ITAB_RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA : ITAB_RETURN1 TYPE STANDARD TABLE OF BAPIRET2.
* Maximum number of lines for DB table
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
* counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,
* cursor
S_CURSOR TYPE CURSOR.
* Select ranges
RANGES: L_R_CARRID FOR SFLIGHT-CARRID,
L_R_CONNID FOR SFLIGHT-CONNID.
* Initialization mode (first call by SAPI) or data transfer mode
* (following calls) ?
* Fill field list table for an optimized select statement
* (in case that there is no 1:1 relation between InfoSource fields
* and database table fields this may be far from beeing trivial)
* Fill range tables BW will only pass down simple selection criteria
* of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
* LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CARRID'.
* MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID.
* APPEND L_R_CARRID.
* ENDLOOP.
*
* LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CONNID'.
* MOVE-CORRESPONDING L_S_SELECT TO L_R_CONNID.
* APPEND L_R_CONNID.
* ENDLOOP.
* Determine number of database records to be read per FETCH statement
* from input parameter I_MAXSIZE. If there is a one to one relation
* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.
* OPEN CURSOR WITH HOLD S_CURSOR FOR
* SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
* WHERE CARRID IN L_R_CARRID AND
* CONNID IN L_R_CONNID.
* ENDIF. "First data package ?
*
SELECT * INTO TABLE ITAB_ORDERADM_H FROM CRMD_ORDERADM_H WHERE PROCESS_TYPE = 'OPPT'.
*
*break-point.
**WA_GUID-GUID = '462844BD5C9E1BA1E100000093225E62'.
*WA_GUID-GUID = '4624FC6748801BA5E100000093225E62'.
*WA_GUID-OBJECT_TYPE = 'OPPT'.
*APPEND WA_GUID TO ITAB_GUID.
**LV_GUID1 = '462844BD5C9E1BA1E100000093225E62'.
*LV_GUID1 = '4624FC6748801BA5E100000093225E62'.
IF SY-SUBRC = 0.
LOOP AT ITAB_ORDERADM_H INTO WA_ORDERADM_H.
LOOP AT ITAB_STATUS INTO WA_STATUS WHERE GUID = WA_GUID-GUID AND USER_STAT_PROC SPACE.
WA_FIELDS-OPPT_STATUS = WA_STATUS-STATUS.
ENDLOOP.
*break-point.
LOOP AT ITAB_PARTNER INTO WA_PARTNER WHERE PARTNER_FCT = '00000015'.
WA_FIELDS-OPPT_CONTACT_PERSON = WA_PARTNER-PARTNER_NO.
ENDLOOP.
* BREAK-POINT.
* LOOP AT ITAB_PRICING INTO WA_PRICING.
* WA_FIELDS-QUOT_CURRENCY = WA_PRICING-CURRENCY.
* ENDLOOP.
* WA_FIELDS-QUOT_CURRENCY = 'USD'.
LOOP AT ITAB_DOC_FLOW INTO WA_DOC_FLOW WHERE OBJTYPE_B = 'BUS2000115'.
WA_GUID1-GUID = WA_DOC_FLOW-OBJKEY_B.
APPEND WA_GUID1 TO ITAB_GUID1.
*BREAK-POINT.
*****GETTING THE QUOTATION DETAILS
CALL FUNCTION 'BAPI_BUSPROCESSND_GETDETAILMUL'
TABLES
GUID = ITAB_GUID1
*PRIORITY
ACTIVITY = ITAB_ACTIVITY1
*HEADER
HEADER = ITAB_HEADER1
*PRODUCT HIERARCHY
PRODUCT = ITAB_PRODUCT1
*PARTNER
PARTNER = ITAB_PARTNER1
*QUANTITY
SCHEDULE_ITEM = ITAB_SCHED1
*EXTERNAL REFERENCE NUMBER
SALES = ITAB_SALES1
*SALES ORGANISATION
ORGANISATION = ITAB_ORGMAN1
*GROSS VALUE AND NET VALUE
PRICING_ITEM = ITAB_PRICING1
*STATUS
STATUS = ITAB_STATUS1
*CLOSING DATE
APPOINTMENT = ITAB_APPOINTMENT1
*ITEM NUMBER
ITEM = ITAB_ITEM1
*EXTERNAL NUMBER
EXT_REF = ITAB_EXT_REF1
*RETURN
RETURN = ITAB_RETURN1.
.
* BREAK-POINT.
LOOP AT ITAB_APPOINTMENT1 INTO WA_APPOINTMENT1 WHERE APPT_TYPE = 'VALIDFROM' AND REF_KIND = 'A'.
WA_FIELDS-QUOT_START_DATE = WA_APPOINTMENT1-DATE_FROM.
ENDLOOP.
SELECT OBJECT_ID INTO WA_FIELDS-DOC_FLOW_GUID FROM CRMD_ORDERADM_H WHERE GUID = WA_DOC_FLOW-OBJKEY_B.
ENDSELECT.
* BREAK-POINT.
LOOP AT ITAB_STATUS1 INTO WA_STATUS1 WHERE GUID = WA_GUID1-GUID AND USER_STAT_PROC SPACE.
WA_FIELDS-QUOT_STATUS = WA_STATUS-STATUS.
ENDLOOP.
LOOP AT ITAB_PARTNER1 INTO WA_PARTNER1 WHERE PARTNER_FCT = '00000014'.
WA_FIELDS-QUOT_PRIMARY = WA_PARTNER1-PARTNER_NO.
ENDLOOP.
CLEAR WA_PARTNER1.
LOOP AT ITAB_HEADER1 INTO WA_HEADER1.
WA_FIELDS-QUOT_UPDATE_BY = WA_HEADER1-CHANGED_BY.
WA_FIELDS-QUOT_CHANGE_DATE = WA_HEADER1-CHANGED_AT.
WA_FIELDS-OPPT_DESC = WA_HEADER1-DESCRIPTION.
ENDLOOP.
LOOP AT ITAB_ITEM1 INTO WA_ITEM1.
WA_FIELDS-QUOT_ITEM_LINE_NUMBER = WA_ITEM1-NUMBER_INT.
WA_FIELDS-QUOT_PRODUCT = WA_ITEM1-ORDERED_PROD.
WA_FIELDS-QUOT_PROD_DESC = WA_ITEM1-DESCRIPTION.
LOOP AT ITAB_PRODUCT1 INTO WA_PRODUCT1 WHERE GUID = WA_ITEM1-GUID.
WA_FIELDS-QUOT_PROD_HIER = WA_PRODUCT1-PROD_HIERARCHY.
ENDLOOP.
* BREAK-POINT.
LOOP AT ITAB_SCHED1 INTO WA_SCHED1 WHERE GUID = WA_ITEM1-GUID.
WA_FIELDS-QUOT_PROD_QUAN = WA_SCHED1-ORDER_QTY.
ENDLOOP.
LOOP AT ITAB_PRICING1 INTO WA_PRICING1 WHERE GUID = WA_ITEM1-GUID.
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
* FETCH NEXT CURSOR S_CURSOR
* APPENDING CORRESPONDING FIELDS
* OF TABLE E_T_DATA
* PACKAGE SIZE S_S_IF-MAXSIZE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.