SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_BUPA_CENTRAL_GETDETAIL



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Apr 26, 2008 6:09 pm    Post subject: BAPI_BUPA_CENTRAL_GETDETAIL Reply with quote

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) ?

  IF I_INITFLAG = SBIWA_C_FLAG_ON.

************************************************************************

* Initialization: check input parameters
* buffer input parameters
* prepare data selection

************************************************************************


* Check DataSource validity

    CASE I_DSOURCE.

* WHEN '0SAPI_SFLIGHT_SIMPLE'.

      WHEN 'ZMGC_DS02'.
      WHEN OTHERS.
        IF 1 = 2. MESSAGE E009(R3). ENDIF.

* this is a typical log call. Please write every error message like this

        LOG_WRITE 'E'                  "message type
                  'R3'                 "message class
                  '009'                "message number
                  I_DSOURCE   "message variable 1
                  ' '.                 "message variable 2
        RAISE ERROR_PASSED_TO_MESS_HANDLER.
    ENDCASE.

    APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.


* Fill parameter buffer for data extraction calls

    S_S_IF-REQUNR    = I_REQUNR.
    S_S_IF-DSOURCE = I_DSOURCE.
    S_S_IF-MAXSIZE   = I_MAXSIZE.


* 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)

    APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.

  ELSE.                 "Initialization mode or data extraction ?

************************************************************************

* Data transfer: First Call      OPEN CURSOR + FETCH
* Following Calls FETCH only

************************************************************************


* First data package -> OPEN CURSOR

    IF S_COUNTER_DATAPAKID = 0.


* 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.

* break-point.

    WA_GUID-GUID = WA_ORDERADM_H-GUID.
    WA_GUID-OBJECT_TYPE = 'OPPT'.
    APPEND WA_GUID TO ITAB_GUID.
    LV_GUID1 = WA_ORDERADM_H-GUID.
*break-point.
    CALL FUNCTION 'BAPI_BUSPROCESSND_GETDETAILMUL'
    TABLES
    GUID = ITAB_GUID
*ACTIVITY
    ACTIVITY = ITAB_ACTIVITY
*HEADER
     HEADER = ITAB_HEADER
*PRODUCT
    PRODUCT = ITAB_PRODUCT
*DOCUMENT FLOW
    DOC_FLOW = ITAB_DOC_FLOW
*ITEM
    ITEM = ITAB_ITEM
*APPOINTMENT
    APPOINTMENT = ITAB_APPOINTMENT
*STATUS
    STATUS = ITAB_STATUS
*PARTNER
    PARTNER =  ITAB_PARTNER
*CLOSING DATE
    OPPORTUNITY = ITAB_OPPORT
*CURREECNY
    PRICING = ITAB_PRICING
*RETURN
    RETURN = ITAB_RETURN.


* BREAK-POINT.


    LOOP AT ITAB_OPPORT INTO WA_OPPORT.
      WA_FIELDS-OPPT_CLOSE_DATE = WA_OPPORT-EXPECT_END.
      DATE_TO = WA_OPPORT-EXPECT_END+4(2).
      CASE DATE_TO.
        WHEN '01'.
          MONTH = 'JAN'.
        WHEN '02'.
          MONTH = 'FEB'.
        WHEN '03'.
          MONTH = '03'.
        WHEN '04'.
          MONTH = 'APR'.
        WHEN '05'.
          MONTH = 'MAY'.
        WHEN '06'.
          MONTH = 'JUN'.
        WHEN '07'.
          MONTH = 'JUL'.
        WHEN '08'.
          MONTH = 'AUG'.
        WHEN '09'.
          MONTH = 'SEP'.
        WHEN '10'.
          MONTH = 'OCT'.
        WHEN '11'.
          MONTH = 'NOV'.
        WHEN '12'.
          MONTH = 'DEC'.
      ENDCASE.
      WA_FIELDS-MONTH = MONTH.

      WA_FIELDS-OPPT_ST_DATE = WA_OPPORT-STARTDATE.
      WA_FIELDS-OPPT_PRIORITY = WA_OPPORT-IMPORTANCE.
    ENDLOOP.

    LOOP AT ITAB_PARTNER INTO WA_PARTNER WHERE PARTNER_FCT = '00000021'.
      WA_FIELDS-OPPT_ACCT_ID = WA_PARTNER-PARTNER_NO.
    ENDLOOP.

    LOOP AT ITAB_PARTNER INTO WA_PARTNER WHERE PARTNER_FCT = '00000014'.
      WA_FIELDS-OPPT_PRIMARY = WA_PARTNER-PARTNER_NO.
    ENDLOOP.
    CLEAR WA_APPOINTMENT.

* BREAK-POINT.

********CUSTOMER FIELDS
    CALL FUNCTION 'CRM_CUSTOMER_H_READ_DB'
      EXPORTING
        IV_GUID          = LV_GUID1
      IMPORTING
        ES_CUSTOMER_H_DB = LS_CUSTOMER
      EXCEPTIONS
        HEADER_DOES_NOT_EXIST = 1
        ERROR_OCCURRED = 2.

* BREAK-POINT.


    WA_FIELDS-OPPT_SITE_ID = LS_CUSTOMER-ZZCUSTOMER_H0401.
    WA_FIELDS-OPPT_HEADER_LVL_PROD = LS_CUSTOMER-ZZCUSTOMER_H0201.

    LOOP AT ITAB_PARTNER INTO WA_PARTNER WHERE PARTNER_FCT = '00000021'.
      LV_BP = WA_PARTNER-PARTNER_NO.

* BREAK-POINT.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = LV_BP
        IMPORTING
          OUTPUT = LV_BP1.
      LS_BP = LV_BP1.

*****ADDRESS*********

* BREAK-POINT.

      CALL FUNCTION 'BAPI_BUPA_ADDRESS_GETDETAIL'
        EXPORTING
          BUSINESSPARTNER = LS_BP
        IMPORTING
          ADDRESSDATA     = LS_ADDRESSDATA
        TABLES
          BAPIADTEL       = ITAB_TEL.

      LV_STREET = LS_ADDRESSDATA-STREET.
      LV_HOUSE_NO = LS_ADDRESSDATA-HOUSE_NO.
      CONCATENATE LV_STREET LV_HOUSE_NO INTO LV_ST_HNO.
      WA_FIELDS-OPPT_ADDRESS1 = LV_ST_HNO.
      WA_FIELDS-OPPT_CITY = LS_ADDRESSDATA-CITY.
      WA_FIELDS-OPPT_STATE = LS_ADDRESSDATA-REGION.
      WA_FIELDS-OPPT_COUNTRY = LS_ADDRESSDATA-COUNTRY.
      WA_FIELDS-OPPT_POSTAL_CODE = LS_ADDRESSDATA-POSTL_COD1.

      LOOP AT ITAB_TEL INTO WA_TEL WHERE CONSNUMBER = '001'.
        WA_FIELDS-OPPT_PHONE = WA_TEL-TELEPHONE.
      ENDLOOP.

******NAME

* BREAK-POINT.

      CALL FUNCTION 'BAPI_BUPA_CENTRAL_GETDETAIL'
        EXPORTING
          BUSINESSPARTNER         = LS_BP
        IMPORTING
          CENTRALDATAPERSON       = LS_CENTRALDATAPERSON
          CENTRALDATA             = LS_CENTRALDATA
          CENTRALDATAORGANIZATION = LS_CENTRALDATAORGANIZATION.
    ENDLOOP.

    IF LS_CENTRALDATA-TITLE_KEY = '0001'.
      LV_FIRSTNAME = LS_CENTRALDATAPERSON-FIRSTNAME.
      LV_LASTNAME = LS_CENTRALDATAPERSON-LASTNAME.
      CONCATENATE LV_FIRSTNAME LV_LASTNAME INTO LV_FULLNAME.
      WA_FIELDS-OPPT_ACCT_NAME = LV_FULLNAME.
    ENDIF.
    IF LS_CENTRALDATA-TITLE_KEY = '0003'.
      WA_FIELDS-OPPT_ACCT_NAME = LS_CENTRALDATAORGANIZATION-NAME1.
    ENDIF.


    LOOP AT ITAB_HEADER INTO WA_HEADER.
      WA_FIELDS-OPPT_ID = WA_HEADER-OBJECT_ID.
      WA_FIELDS-OPPT_DESC = WA_HEADER-DESCRIPTION.
      WA_FIELDS-QUOT_CR_DATE = WA_HEADER-CREATED_AT.
      WA_FIELDS-OPPT_CHAN_BY = WA_HEADER-CHANGED_BY.
      WA_FIELDS-OPPT_CHAN_DT = WA_HEADER-CHANGED_AT.
      WA_FIELDS-QUOT_DESC = WA_HEADER-DESCRIPTION.
    ENDLOOP.

    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.

          WA_FIELDS-QUOT_GROSS_VALUE = WA_PRICING1-SUBTOTAL1.
          WA_FIELDS-QUOT_PROD_UNIT_PRICE = WA_FIELDS-QUOT_GROSS_VALUE / WA_FIELDS-QUOT_PROD_QUAN.
          WA_FIELDS-QUOT_NET_VALUE = WA_PRICING1-NET_VALUE.
          WA_FIELDS-QUOT_CURRENCY = WA_PRICING1-CURRENCY.
          LV_SUBTOTAL1 = WA_PRICING1-SUBTOTAL1.
          LV_NETVALUE = WA_PRICING1-NET_VALUE.
        ENDLOOP.

* ENDLOOP.

        LOOP AT ITAB_ORGMAN1 INTO WA_ORGMAN1 WHERE REF_KIND = 'A'.
          WA_FIELDS-QUOT_SALES_ORG = WA_ORGMAN1-SALES_ORG_SHORT.
        ENDLOOP.


* BREAK-POINT.


        LOOP AT ITAB_EXT_REF1 INTO WA_EXT_REF1.
          WA_FIELDS-QUOT_EXT_NUM = WA_EXT_REF1-REFERENCE_NUMBER.
        ENDLOOP.

        WA_FIELDS-QUOT_DISCOUNT = LV_SUBTOTAL1 - LV_NETVALUE.

        CLEAR WA_DOC_FLOW.

        CLEAR MONTH.
        CLEAR DATE_TO.
        CLEAR ITAB_ACTIVITY1.
        CLEAR ITAB_HEADER1.
        CLEAR WA_HEADER1.
        CLEAR  ITAB_PARTNER1.
        CLEAR WA_PARTNER1.

* CLEAR ITAB_SCHED1.

        CLEAR WA_SCHED1.
        CLEAR ITAB_SALES1.
        CLEAR WA_SALES1.
        CLEAR ITAB_ORGMAN1.
        CLEAR WA_ORGMAN1.

* CLEAR ITAB_PRICING1.

        CLEAR WA_PRICING1.
        CLEAR ITAB_STATUS1.
        CLEAR WA_STATUS1.
        CLEAR ITAB_APPOINTMENT1.
        CLEAR WA_APPOINTMENT1.
        CLEAR ITAB_EXT_REF1.
        CLEAR WA_EXT_REF1.
*****************

* CLEAR ITAB_PRODUCT1.
* CLEAR WA_PRODUCT1.
* CLEAR ITAB_SCHED1.
* CLEAR WA_SCHED1.
* CLEAR ITAB_PRICING1.
* CLEAR WA_PRICING1.
* CLEAR ITAB_ORGMAN1.
* CLEAR WA_ORGMAN1.
* CLEAR ITAB_EXT_REF1.
* CLEAR WA_EXT_REF1.

        LOOP AT ITAB_PRICING INTO WA_PRICING.
         WA_FIELDS-QUOT_CURRENCY = WA_PRICING-CURRENCY.
        ENDLOOP.

        APPEND WA_FIELDS TO ITAB_FIELDS.
      ENDLOOP.
       CLEAR ITAB_ITEM1.
       CLEAR WA_ITEM1.
       CLEAR ITAB_PRODUCT1.
       CLEAR WA_PRODUCT1.
       CLEAR WA_DOC_FLOW.
       CLEAR WA_GUID1.
       CLEAR ITAB_GUID1.
    ENDLOOP.
     CLEAR WA_ORDERADM_H.
     CLEAR WA_FIELDS.
     CLEAR ITAB_HEADER.
     CLEAR WA_HEADER.
     CLEAR ITAB_PRODUCT.
     CLEAR WA_PRODUCT.
     CLEAR ITAB_PRICING.
     CLEAR WA_PRICING.
     CLEAR ITAB_PARTNER.
     CLEAR WA_PARTNER.
     CLEAR ITAB_STATUS.
     CLEAR WA_STATUS.
     CLEAR ITAB_APPOINTMENT.
     CLEAR WA_APPOINTMENT.
     CLEAR ITAB_DOC_FLOW.
     CLEAR WA_GUID.
     CLEAR ITAB_GUID.
     CLEAR LV_GUID1.
     CLEAR LS_CUSTOMER.
     CLEAR LV_BP.
     CLEAR LV_BP1.
  ENDLOOP.
ENDIF.
*BREAK-POINT.



* 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.

 loop at ITAB_FIELDS into WA_FIELDS1 .

 WA_ZMG-zop_csid =   WA_FIELDS1-OPPT_ACCT_ID .
 WA_ZMG-zop_cnm  =   WA_FIELDS1-OPPT_ACCT_NAME .
 WA_ZMG-zop_cty = WA_FIELDS1-OPPT_CITY.
 WA_ZMG-zop_cdt = WA_FIELDS1-OPPT_CLOSE_DATE .
 WA_ZMG-zop_mnth = WA_FIELDS1-MONTH .
 WA_ZMG-zop_inm = WA_FIELDS1-OPPT_CONTACT_PERSON .
 WA_ZMG-zop_ctry = WA_FIELDS1-OPPT_COUNTRY.
 WA_ZMG-zop_crdt = WA_FIELDS1-QUOT_CR_DATE.
 WA_ZMG-zop_oid =  WA_FIELDS1-QUOT_EXT_NUM .
 WA_ZMG-zop_fst = WA_FIELDS1-OPPT_STATUS.
 WA_ZMG-zop_lid = WA_FIELDS1-QUOT_ITEM_LINE_NUMBER .
 WA_ZMG-zop_updt2 = WA_FIELDS1-OPPT_CHAN_DT.
 WA_ZMG-zop_desc = WA_FIELDS1-OPPT_DESC .
 WA_ZMG-zop_inid = WA_FIELDS1-OPPT_ID .
 WA_ZMG-zop_iprty = WA_FIELDS1-OPPT_PRIORITY.
 WA_ZMG-zop_up2 = WA_FIELDS1-OPPT_CHAN_BY .
 WA_ZMG-zop_pc = WA_FIELDS1-OPPT_POSTAL_CODE .
 WA_ZMG-zop_insby = WA_FIELDS1-QUOT_PRIMARY .
 WA_ZMG-zop_inby = WA_FIELDS1-OPPT_PRIMARY .
 WA_ZMG-zop_prod = WA_FIELDS1-QUOT_PRODUCT .
 WA_ZMG-zop_prds = WA_FIELDS1-QUOT_PROD_DESC .
 WA_ZMG-zop_phr = WA_FIELDS1-QUOT_PROD_HIER .
 WA_ZMG-zop_prno = WA_FIELDS1-QUOT_PROD_QUAN .
 WA_ZMG-zop_qty =  WA_FIELDS1-QUOT_PROD_QUAN.
 WA_ZMG-zop_qnm = WA_FIELDS1-QUOT_DESC .
 WA_ZMG-zop_qid = WA_FIELDS1-DOC_FLOW_GUID .
 WA_ZMG-zop_qupby = WA_FIELDS1-QUOT_UPDATE_BY.
 WA_ZMG-zop_qdt = WA_FIELDS1-QUOT_CHANGE_DATE .
 WA_ZMG-zop_qinb = WA_FIELDS1-QUOT_PRIMARY .
 WA_ZMG-zop_qidt = WA_FIELDS1-QUOT_START_DATE .
 WA_ZMG-zop_sreg = WA_FIELDS1-QUOT_SALES_ORG.
 WA_ZMG-zop_spid = WA_FIELDS1-OPPT_SITE_ID .
 WA_ZMG-zop_incdt = WA_FIELDS1-OPPT_ST_DATE .
 WA_ZMG-zop_st =  WA_FIELDS1-OPPT_STATE .
 WA_ZMG-zop_stsq = WA_FIELDS1-QUOT_STATUS .
 WA_ZMG-zop_ad1 = WA_FIELDS1-OPPT_ADDRESS1.

* zmg_struct_02-zop_up = WA_FIELDS1-QUOT_PROD_UNIT_PRICE .
* zmg_struct_02-zop_glir = WA_FIELDS1-QUOT_GROSS_VALUE .
* zmg_struct_02-zop_td =  WA_FIELDS1-QUOT_DISCOUNT .
* zmg_struct_02-zop_nlir = WA_FIELDS1-QUOT_NET_VALUE .

*

     append WA_ZMG TO ITAB_ZMG.

     CLEAR WA_ZMG.
     endloop.

* endloop.


       clear E_T_DATA.

      refresh E_T_DATA.

      E_T_DATA = ITAB_ZMG.


    IF SY-SUBRC  0.
      CLOSE CURSOR S_CURSOR.
      RAISE NO_MORE_DATA.
    ENDIF.

    else.
* raise no_more_data.

    S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

  ENDIF.              "Initialization mode or data extraction ?
  ENDIF .


ENDFUNCTION.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.