1. 程式人生 > 實用技巧 >物料成本估算細項明細——BAPI_COSTESTIMATE_GETEXPLOSION

物料成本估算細項明細——BAPI_COSTESTIMATE_GETEXPLOSION

效果:

對比CK13N:

程式碼:

************************************************************************
* Program Name      :
* Descriptions      :
* T-Code            :
* Updates Tables    :
* Input  Parameters :
* Output Parameters :
* Return Codes      :
* Special Logic     :
* Includes          :
************************************************************************
* Modification Log ************************************************************************ * Date Ver. Programmer Descriptions * -------- ---- ------------ ------------------------------------------- * 2020/09/20 xxx Create * ************************************************************************
REPORT ZCORTEST4. *********************************************************************** * Tables Definitions ************************************************************************ *TABLES:. ************************************************************************ TABLES: mara. * Data Definitions
************************************************************************ DATA: gt_list TYPE TABLE OF bapiexplosionlist, gs_return TYPE bapireturn. TYPE-POOLS: slis. DATA: gs_layout TYPE slis_layout_alv, gt_fieldcat TYPE slis_t_fieldcat_alv. ************************************************************************ * Includes Module ************************************************************************ ************************************************************************ * Selection Screen ************************************************************************ SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01. PARAMETERS: p_werks LIKE marc-werks DEFAULT '2000', p_matnr LIKE marc-matnr DEFAULT 'CTYN0326-XX', p_lot LIKE bapicostes-lotsize DEFAULT 100, p_sicht LIKE tckh8-sicht DEFAULT '01'. SELECTION-SCREEN END OF BLOCK b1. ************************************************************************ * Initialization ************************************************************************ INITIALIZATION. ************************************************************************ * At Selection Screen ************************************************************************ AT SELECTION-SCREEN. ************************************************************************ * At Selection Screen Output ************************************************************************ AT SELECTION-SCREEN OUTPUT. ************************************************************************ * Report Format ************************************************************************ TOP-OF-PAGE. END-OF-PAGE. ************************************************************************ * Main Process ************************************************************************ START-OF-SELECTION. PERFORM get_data. PERFORM display_data. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Form GET_DATA *&---------------------------------------------------------------------* FORM get_data. DATA: lt_keko TYPE TABLE OF keko, ls_keko TYPE keko. SELECT * INTO TABLE lt_keko FROM keko WHERE werks = p_werks AND matnr = p_matnr. SORT lt_keko BY kalnr DESCENDING. READ TABLE lt_keko INTO ls_keko INDEX 1. CALL FUNCTION 'BAPI_COSTESTIMATE_GETEXPLOSION' EXPORTING referenceobject = ls_keko-bzobj "KEKO-BZOBJ costingnumber = ls_keko-kalnr "KEKO-KALNR costingtype = ls_keko-kalka "KEKO-KALKA costingdate = ls_keko-kadky "KEKO-KADKY costingversion = ls_keko-tvers "KEKO-TVERS valuationvariant = ls_keko-bwvar "KEKO-BWVAR enteredmanually = ls_keko-kkzma "KEKO-KKZMA cost_component_view = p_sicht "TCKH8-SICHT * explosion_depth = lot_size = p_lot * explode_kf_too = ' ' IMPORTING * explosion_incomplete = return = gs_return TABLES explosion_list = gt_list. ENDFORM. "GET_DATA *&---------------------------------------------------------------------* *& Form DISPLAY_DATA *&---------------------------------------------------------------------* FORM display_data. DATA: l_repid TYPE sy-repid, l_inclname TYPE trdir-name, l_index LIKE sy-tabix. l_repid = l_inclname = sy-cprog. "欄位最適寬度 gs_layout-colwidth_optimize = 'X'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = l_repid i_structure_name = 'BAPIEXPLOSIONLIST' i_inclname = l_inclname CHANGING ct_fieldcat = gt_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. LOOP AT gt_fieldcat INTO DATA(ls_fieldcat). IF ls_fieldcat-fieldname = 'CCODE_CURRENCY_TOTAL_VALUE' OR ls_fieldcat-fieldname ='CCODE_CURRENCY_FIXED_VALUE'. ls_fieldcat-emphasize = 'C310'. ENDIF. MODIFY gt_fieldcat FROM ls_fieldcat. ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid is_layout = gs_layout it_fieldcat = gt_fieldcat i_save = 'A' TABLES t_outtab = gt_list EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. "DISPLAY_DATA