Add two attributes to the class as below. Since the class is for purchase order, the key should be with type EKKO-EBELN
METHOD constructor.
DATA(lv_class_name) = cl_abap_classdescr=>get_class_name( me ).
SPLIT lv_class_name+1 AT '=' INTO TABLE DATA(lt_class_name).
me->_por-catid = lt_class_name[ 1 ].
me->_por-typeid = lt_class_name[ 2 ].
me->_por-instid = im_order.
ME->_key = im_order.
ENDMETHOD.
METHOD bi_persistent~find_by_lpor.
DATA(lv_order) = CONV ebeln( lpor-instid(10) ).
result = NEW zcl_purchase_order( lv_order ).
ENDMETHOD.
METHOD bi_persistent~lpor.
result = _por.
ENDMETHOD.
FUNCTION zaci_event_to_json .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IR_DATA) TYPE DATA
*" VALUE(IV_INSTANCE) TYPE /ASADEV/AMR_ARIBA_ARIBA_INST
*" VALUE(IV_OBJECT) TYPE /ASADEV/AMR_ARIBA_ARIBA_OBJECT
*" EXPORTING
*" REFERENCE(ET_CSV_LINES) TYPE /ASADEV/AMR_TT_CSV_LINE
*" REFERENCE(ET_RETURN) TYPE /ASADEV/ACI_TT_BAPIRET2
*"----------------------------------------------------------------------
DATA:
lt_csv_lines TYPE /asadev/amr_tt_csv_line, "
lt_csv_bundle TYPE /asadev/amr_tt_csv_line, "
ls_amr_obj TYPE /asadev/amr_obj, "
ls_csv_line TYPE LINE OF /asadev/amr_tt_csv_line.
CONSTANTS: lc_attr_db_name TYPE /asadev/aci_def_attr VALUE 'ACI_VIEW'.
FIELD-SYMBOLS: <ft_data> TYPE ANY TABLE.
"get the data:
ASSIGN ir_data->* TO <ft_data>.
IF sy-subrc NE 0 OR <ft_data> IS INITIAL.
RETURN.
ENDIF.
" convert data into json
DATA(lv_json) = /ui2/cl_json=>serialize(
data = <ft_data>
pretty_name = /ui2/cl_json=>pretty_mode-low_case ).
APPEND lv_json to lt_csv_lines.
ls_amr_obj = /asadev/cl_aci_helper=>get_aci_object(
iv_instance = iv_instance
iv_object = iv_object ).
*MOD-003 bundle as many csv_lines as customized into one cloud event
LOOP AT lt_csv_lines INTO ls_csv_line.
APPEND ls_csv_line TO lt_csv_bundle.
IF lines( lt_csv_bundle ) EQ ls_amr_obj-item_lines.
" now wrap the payload in the cloudevents header
CALL FUNCTION '/ASADEV/ACI_SAP_EM_CLOUDEV_FM'
EXPORTING
it_csv_lines = lt_csv_bundle
iv_instance = iv_instance
iv_object = iv_object
IMPORTING
et_csv_lines = lt_csv_bundle
et_return = et_return.
APPEND LINES OF lt_csv_bundle TO et_csv_lines.
IF ls_amr_obj-item_lines GT 0.
DO ls_amr_obj-item_lines - 1 TIMES.
APPEND INITIAL LINE TO et_csv_lines.
ENDDO.
ENDIF.
CLEAR lt_csv_bundle.
ENDIF.
ENDLOOP.
"Append the remaining lines
IF lines( lt_csv_bundle ) GE 1.
CALL FUNCTION '/ASADEV/ACI_SAP_EM_CLOUDEV_FM'
EXPORTING
it_csv_lines = lt_csv_bundle
iv_instance = iv_instance
iv_object = iv_object
IMPORTING
et_csv_lines = lt_csv_bundle
et_return = et_return.
APPEND LINES OF lt_csv_bundle TO et_csv_lines.
IF ls_amr_obj-item_lines GT 0.
DO ls_amr_obj-item_lines - 1 TIMES.
APPEND INITIAL LINE TO et_csv_lines.
ENDDO.
ENDIF.
CLEAR lt_csv_bundle.
ENDIF.
ENDFUNCTION.
FUNCTION zaci_event_extractor .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_INSTANCE) TYPE /ASADEV/AMR_ARIBA_ARIBA_INST
*" REFERENCE(IV_OBJECT) TYPE /ASADEV/AMR_ARIBA_ARIBA_OBJECT
*" REFERENCE(IT_BDCP_LINES) TYPE /ASADEV/ACI_TT_BDCP
*" EXPORTING
*" REFERENCE(ET_RETURN) TYPE /ASADEV/ACI_TT_BAPIRET2
*" REFERENCE(ET_KEY_BDCP) TYPE /ASADEV/ACI_TT_BDCP_KEY
*" REFERENCE(ET_TABLE_CONTENT) TYPE /ASADEV/ACI_TT_TABLE_CONTENT
*" REFERENCE(ER_DATA) TYPE REF TO DATA
*" EXCEPTIONS
*" NOT_A_VALID_TABLE
*"----------------------------------------------------------------------
DATA: lo_badi TYPE REF TO /asadev/aci_gen_extractor_badi,
ct_table_content TYPE /asadev/aci_tt_table_content,
lr_dataref_t TYPE REF TO data.
* Get BAdI instance for extractor enhancements
/asadev/cl_aci_badi_helpr=>get_extr_badi(
EXPORTING
iv_instance = iv_instance
iv_object = iv_object
CHANGING
co_extractor_badi = lo_badi
ct_return = et_return ).
IF lo_badi IS BOUND.
/asadev/cl_aci_badi_helpr=>call_badi_extr_post_exit(
EXPORTING
io_extractor_badi = lo_badi
iv_instance = iv_instance
iv_object = iv_object
it_bdcp_lines = it_bdcp_lines
CHANGING
ct_table_content = ct_table_content
ct_return = et_return
cr_data = lr_dataref_t ).
ENDIF.
er_data = lr_dataref_t.
ENDFUNCTION.
METHOD /asadev/aci_extrctpr_if~post_exit.
DATA lr_dataref TYPE REF TO data.
DATA(lv_order) = CONV ebeln( it_bdcp_lines[ 1 ]-tabkey+35 ). " Get PO number
DATA:
ls_data TYPE zpurchase_order.
FIELD-SYMBOLS:
<ls_purchase_order> type zpurchase_order,
<lt_purchase_order> TYPE STANDARD TABLE.
CREATE DATA lr_dataref TYPE TABLE OF zpurchase_order.
ASSIGN lr_dataref->* TO <lt_purchase_order>.
APPEND INITIAL LINE TO <lt_purchase_order> ASSIGNING <ls_purchase_order>.
SELECT SINGLE *
FROM ekko
INTO @DATA(ls_ekko)
WHERE ebeln EQ @lv_order.
SELECT *
FROM ekpo
INTO TABLE @DATA(lt_ekpo)
WHERE ebeln EQ @lv_order.
<ls_purchase_order> = VALUE #(
order_id = lv_order
header_text = ''
).
LOOP AT lt_ekpo ASSIGNING FIELD-SYMBOL(<ls_ekpo>).
APPEND INITIAL LINE TO <ls_purchase_order>-items ASSIGNING FIELD-SYMBOL(<ls_item>).
<ls_item>-item_number = <ls_ekpo>-ebelp.
<ls_item>-item_text = <ls_ekpo>-txz01.
<ls_item>-material = <ls_ekpo>-matnr.
<ls_item>-quantity = <ls_ekpo>-menge.
<ls_item>-uom = <ls_ekpo>-meins.
ENDLOOP.
cr_data = lr_dataref.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |