Code: Alles auswählen.
Attribute
ST_FIELDNAMES_KNB1_APPEND Static Attribute Protected Type FIELDNAME_TAB Tabelle von Feldnamen
AT_SELDATA Instance Attribute Protected Type MASS_TABDATA Tabelle mit den Änderungsinfos (Massenpflege)
AT_SKNB1 Instance Attribute Protected Type STT_SKNB1 KNB1-Daten
AV_KUNNR Instance Attribute Protected Type KUNNR Debitorennummer
Code: Alles auswählen.
METHOD class_constructor.
* Read fieldnames of KNB1-append
DATA:
lo_structdescr TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS:
<ls_component> LIKE LINE OF lo_structdescr->components.
*
lo_structdescr ?= cl_abap_structdescr=>describe_by_name( 'ZST_KNB1_APPEND' ).
* No error handling: If type not exists than we have to stop processing in every case.
LOOP AT lo_structdescr->components[] ASSIGNING <ls_component>.
INSERT <ls_component>-name INTO TABLE st_fieldnames_knb1_append[].
ENDLOOP.
ENDMETHOD.
Code: Alles auswählen.
METHOD if_ex_customer_add_data_bi~modify_bi_struct_from_std_seg.
*--------------------------------------------------------------------*
* The additional fields have to be filled, but there are no interface
* to the additional data. So the implizit enhancement of function
* module MASS_DEBMAS03_CHANGE at the beginning is used to export the
* data. Now we can import them here.
*--------------------------------------------------------------------*
DATA:
ls_e1kna1m TYPE e1kna1m,
ls_e1knb1m TYPE e1knb1m.
*
CASE i_segment_name.
WHEN 'E1KNA1M'.
ls_e1kna1m = i_segment_data.
me->av_kunnr = ls_e1kna1m-kunnr.
WHEN 'E1KNB1M'.
CLEAR:
me->at_sknb1[],
me->at_seldata[].
IMPORT sknb1 TO me->at_sknb1[] seldata TO me->at_seldata[] FROM MEMORY ID 'ZKNB1_APPEND_01'.
IF sy-subrc = 0. "Import ok -> it means we are called from XD99
ls_e1knb1m = i_segment_data.
me->modify_bknb1_from_xd99( EXPORTING
iv_nodata = i_nodata
is_e1knb1m = ls_e1knb1m
CHANGING
es_bi_struct = e_bi_struct ).
* ELSE.
* NOP
ENDIF.
* WHEN OTHERS.
* NOP
ENDCASE.
ENDMETHOD.
Code: Alles auswählen.
METHOD modify_bknb1_from_xd99.
DATA:
ls_knb1_additonal_data TYPE zst_knb1_append.
FIELD-SYMBOLS:
<lv_field_knb1> TYPE any,
<lv_field_additional_data> TYPE any,
<ls_bknb1> TYPE bknb1,
<ls_seldata> LIKE LINE OF me->at_seldata,
<lv_fieldname> LIKE LINE OF <ls_seldata>-fieldnames, "fields to change in XD99
<ls_knb1> TYPE knb1.
*
* The additional fields are in structure ls_knb1_additonal_data.
* The structure is in the CI-Include of BKNA1 contained.
* If you make an ALE-Enhancement the fields should have the same names.
ASSIGN es_bi_struct TO <ls_bknb1> CASTING ##ENH_OK.
IF <ls_bknb1> IS ASSIGNED.
* get all values of the additional data from BI structure into local store (fields to change and not to change)
MOVE-CORRESPONDING <ls_bknb1> TO ls_knb1_additonal_data.
* read corresponding KNB1 data (new values) with the current company code and customer number
READ TABLE me->at_sknb1[] ASSIGNING <ls_knb1> WITH KEY kunnr = av_kunnr bukrs = is_e1knb1m-bukrs(4).
IF sy-subrc IS INITIAL.
* fields to change in current XD99 call are in at_seldata[]
READ TABLE me->at_seldata[] INDEX 1 ASSIGNING <ls_seldata>.
LOOP AT <ls_seldata>-fieldnames ASSIGNING <lv_fieldname>.
* current field to change has to be in both structures ls_knb1_additonal_data and knb1
ASSIGN COMPONENT <lv_fieldname> OF STRUCTURE ls_knb1_additonal_data TO <lv_field_additional_data>.
IF sy-subrc IS INITIAL.
ASSIGN COMPONENT <lv_fieldname> OF STRUCTURE <ls_knb1> TO <lv_field_knb1>.
IF sy-subrc IS INITIAL.
* copy value from knb1 into local additional data
WRITE <lv_field_knb1> TO <lv_field_additional_data> ##WRITE_MOVE.
* ELSE.
* NOP
ENDIF.
* ELSE.
* NOP
ENDIF.
ENDLOOP.
* copy all values (changed and unchanged fields) from additional data structure into bi structure (export structure)
MOVE-CORRESPONDING ls_knb1_additonal_data TO <ls_bknb1>.
* ELSE.
* NOP
ENDIF.
* ELSE.
* NOP
ENDIF.
ENDMETHOD.
Code: Alles auswählen.
METHOD if_ex_customer_add_data_bi~fill_ft_table_using_data_rows.
DATA:
lv_dynpro_reached TYPE abap_bool VALUE abap_false,
ls_bknb1 TYPE bknb1.
FIELD-SYMBOLS:
<ls_bdcdata> TYPE bdcdata,
<lv_field_bknb1> TYPE any,
<lv_fieldname> LIKE LINE OF st_fieldnames_knb1_append[],
<ls_data_row> LIKE LINE OF it_data_rows[].
*
LOOP AT it_data_rows[] ASSIGNING <ls_data_row>.
CASE <ls_data_row>(31).
WHEN '2BKNB1'."only BI structure for knb1 is of interesting
ls_bknb1 = <ls_data_row> ##ENH_OK.
LOOP AT st_fieldnames_knb1_append[] ASSIGNING <lv_fieldname>."only current change fields
ASSIGN COMPONENT <lv_fieldname> OF STRUCTURE ls_bknb1 TO <lv_field_bknb1>.
IF sy-subrc IS INITIAL."change field is in bknb1 included
IF <lv_field_bknb1> NE i_nodata.
IF lv_dynpro_reached EQ abap_false.
* jump to additional data
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-fnam = 'BDC_OKCODE'.
<ls_bdcdata>-fval = 'BAOZM'. "BAO + Name of screen group in customizing
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-program = 'SAPMF02D'.
<ls_bdcdata>-dynpro = '4000'.
<ls_bdcdata>-dynbegin = 'X'.
* jump to tab page within additional data
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-fnam = 'BDC_OKCODE'.
<ls_bdcdata>-fval = 'DEFINED_FUNCTION_CODE'. "Function code of TAB Page in customizing
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-program = 'SAPMF02D'.
<ls_bdcdata>-dynpro = '4000'.
<ls_bdcdata>-dynbegin = 'X'.
lv_dynpro_reached = abap_true.
* ELSE.
* NOP - dynpro reached, no jump into dynpro necessary
ENDIF.
* set new field value
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
CONCATENATE 'ZST_KNB1_APPEND-' <lv_fieldname> INTO <ls_bdcdata>-fnam.
<ls_bdcdata>-fval = <lv_field_bknb1>.
* ELSE.
* NOP - no change of field value necessary
ENDIF.
* ELSE.
* NOP - field not part of structure bknb1
ENDIF.
ENDLOOP.
ENDCASE.
ENDLOOP.
ENDMETHOD.
Code: Alles auswählen.
FUNCTION mass_debmas03_change .
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Funktionsbaustein MASS_DEBMAS03_CHANGE, Anfang A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 Z_MASS_DEBMAS03_CHANGE_S. "active version
EXPORT SKNB1[] SELDATA[] to memory id 'ZKNB1_APPEND_01'.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*
Code: Alles auswählen.
AT_SKNB1 Instance Attribute Protected Type STT_SKNB1 KNB1-Daten
Code: Alles auswählen.
METHOD if_ex_customer_add_data_bi~fill_ft_table_using_data_rows.
DATA:
lv_dynpro_reached TYPE abap_bool VALUE abap_false,
ls_bknvv TYPE bknvv.
FIELD-SYMBOLS:
<ls_bdcdata> TYPE bdcdata,
<lv_field_bknvv> TYPE any,
<lv_fieldname> LIKE LINE OF st_fieldnames_knvv_append[],
<ls_data_row> LIKE LINE OF it_data_rows[].
*
LOOP AT it_data_rows[] ASSIGNING <ls_data_row>.
CASE <ls_data_row>(31).
WHEN '2BKNVV'."only BI structure for 'KNVV' is of interesting
ls_bknvv = <ls_data_row> ##ENH_OK.
LOOP AT st_fieldnames_knvv_append[] ASSIGNING <lv_fieldname>."only current change fields
ASSIGN COMPONENT <lv_fieldname> OF STRUCTURE ls_bknvv TO <lv_field_bknvv>.
IF sy-subrc IS INITIAL."change field is in bknb1 included
IF <lv_field_bknvv> NE i_nodata.
IF lv_dynpro_reached EQ abap_false.
* jump to additional data
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-fnam = 'BDC_OKCODE'.
<ls_bdcdata>-fval = 'BAOZB'. "BAO + Name of screen group in customizing
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-program = 'SAPMF02D'.
<ls_bdcdata>-dynpro = '4000'.
<ls_bdcdata>-dynbegin = 'X'.
* jump to tab page within additional data
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-fnam = 'BDC_OKCODE'.
<ls_bdcdata>-fval = 'ZB_TAB1'. "Function code of TAB Page in customizing
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
<ls_bdcdata>-program = 'SAPMF02D'.
<ls_bdcdata>-dynpro = '4000'.
<ls_bdcdata>-dynbegin = 'X'.
lv_dynpro_reached = abap_true.
* ELSE.
* NOP - dynpro reached, no jump into dynpro necessary
ENDIF.
* set new field value
INSERT INITIAL LINE INTO TABLE et_ft[] ASSIGNING <ls_bdcdata>.
CONCATENATE 'ZZCUST_ENHA_BKNVV-' <lv_fieldname> INTO <ls_bdcdata>-fnam.
<ls_bdcdata>-fval = <lv_field_bknvv>.
* ELSE.
* NOP - no change of field value necessary
ENDIF.
* ELSE.
* NOP - field not part of structure bknb1
ENDIF.
ENDLOOP.
ENDCASE.
ENDLOOP.
ENDMETHOD.