*&---------------------------------------------------------------------*
*& Report Y_A0287_004
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT XX
*--------------------------------------------------------------------*
* パラメータ
*--------------------------------------------------------------------*
PARAMETERS:
pa_ptn(1) TYPE c.
*--------------------------------------------------------------------*
* START-OF-SELECTION
*--------------------------------------------------------------------*
START-OF-SELECTION.
FIELD-SYMBOLS:
<dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
ifc type lvc_t_fcat,
xfc type lvc_s_fcat.
CASE pa_ptn.
WHEN '1'.
* xfc-inttypeが必要
xfc-fieldname = 'sod_hk_dt'.
xfc-datatype = 'DATS'.
xfc-inttype = 'DATS'.
xfc-intlen = 8.
append xfc to ifc.
xfc-fieldname = 'ordno'.
xfc-datatype = 'C'.
xfc-inttype = 'C'.
xfc-intlen = 14.
append xfc to ifc.
xfc-fieldname = 'posno'.
xfc-datatype = 'C'.
xfc-inttype = 'C'.
xfc-intlen = 5.
append xfc to ifc.
WHEN '2'.
xfc-fieldname = 'ordno'.
xfc-datatype = 'C'.
xfc-intlen = 14.
xfc-decimals = 0.
append xfc to ifc.
xfc-fieldname = 'posno'.
xfc-datatype = 'C'.
xfc-intlen = 5.
xfc-decimals = 0.
append xfc to ifc.
xfc-fieldname = 'sod_hk_dt'.
xfc-datatype = 'DATS'.
xfc-intlen = 8.
xfc-decimals = 0.
append xfc to ifc.
WHEN '3'.
xfc-fieldname = 'sod_hk_dt'.
xfc-datatype = 'DATS'.
xfc-intlen = 8.
xfc-decimals = 0.
append xfc to ifc.
xfc-fieldname = 'posno'.
xfc-datatype = 'C'.
xfc-intlen = 5.
xfc-decimals = 0.
append xfc to ifc.
xfc-fieldname = 'ordno'.
xfc-datatype = 'C'.
xfc-intlen = 14.
xfc-decimals = 0.
append xfc to ifc.
WHEN OTHERS.
ENDCASE.
xfc-fieldname = 'objid'.
xfc-datatype = 'C'.
xfc-inttype = 'C'.
xfc-intlen = 10.
append xfc to ifc.
xfc-fieldname = 'kg_curcy'.
xfc-datatype = 'CUKY'.
xfc-inttype = 'CUKY'.
xfc-intlen = 5.
append xfc to ifc.
xfc-fieldname = 'urihyo_kg'.
xfc-datatype = 'CURR'.
xfc-inttype = 'P'.
xfc-intlen = 15.
xfc-decimals = 2.
append xfc to ifc.
call method cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
* xxデータ抽出
PERFORM fm_get_t0320 CHANGING <dyn_table>.
*--------------------------------------------------------------------*
* END-OF-SELECTION
*--------------------------------------------------------------------*
END-OF-SELECTION.
IF <dyn_table> IS NOT INITIAL.
* 一覧出力
PERFORM fm_output USING <dyn_table>.
ENDIF.
*--------------------------------------------------------------------*
* サブルーチン
*--------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form fm_get_t0320
*&---------------------------------------------------------------------*
* xxデータ抽出
*----------------------------------------------------------------------*
* <--C_ITAB_T0320 xxデータITAB
*----------------------------------------------------------------------*
FORM fm_get_t0320 CHANGING c_itab_t0320 TYPE standard table.
SELECT ordno " オーダ№
sod_hk_dt " 主オーダ発行日
posno " POSNO
objid " トランザクション ID
kg_curcy " 通貨コード
urihyo_kg " 売上社内合価
FROM zbusa_t0320
INTO CORRESPONDING FIELDS OF TABLE c_itab_t0320.
IF sy-subrc <> 0.
MESSAGE text-m01 TYPE 'S'.
ENDIF.
ENDFORM. "fm_get_t0320
*&---------------------------------------------------------------------*
*& Form fm_output
*&---------------------------------------------------------------------*
* 一覧出力
*----------------------------------------------------------------------*
* -->U_ITAB_T0320 売上伝票明細データITAB
*----------------------------------------------------------------------*
FORM fm_output USING u_itab_t0320 TYPE standard table.
DATA:
l_c_label1(20) TYPE c,
l_c_label2(20) TYPE c,
otab TYPE abap_sortorder_tab,
oline TYPE abap_sortorder,
l_c_label3(20) TYPE c.
FIELD-SYMBOLS:
<f1> TYPE ANY,
<f2> TYPE ANY,
<f3> TYPE ANY,
<fs_field1> TYPE ANY,
<fs_field2> TYPE ANY,
<fs_field3> TYPE ANY.
create data dy_line like line of u_itab_t0320.
assign dy_line->* to <dyn_wa>.
CASE pa_ptn.
WHEN '1'.
* 大文字が必要
ASSIGN COMPONENT 'SOD_HK_DT' OF STRUCTURE <dyn_wa> TO <fs_field1>.
ASSIGN COMPONENT 'ORDNO' OF STRUCTURE <dyn_wa> TO <fs_field2>.
ASSIGN COMPONENT 'POSNO' OF STRUCTURE <dyn_wa> TO <fs_field3>.
oline-name = 'SOD_HK_DT'.
APPEND oline TO otab.
oline-name = 'ORDNO'.
APPEND oline TO otab.
oline-name = 'POSNO'.
APPEND oline TO otab.
SORT u_itab_t0320 BY (otab).
l_c_label1 = text-r01.
l_c_label2 = text-r02.
l_c_label3 = text-r03.
WHEN '2'.
ASSIGN COMPONENT 'ORDNO' OF STRUCTURE <dyn_wa> TO <fs_field1>.
ASSIGN COMPONENT 'POSNO' OF STRUCTURE <dyn_wa> TO <fs_field2>.
ASSIGN COMPONENT 'SOD_HK_DT' OF STRUCTURE <dyn_wa> TO <fs_field3>.
l_c_label1 = text-r02.
l_c_label2 = text-r03.
l_c_label3 = text-r01.
oline-name = 'ORDNO'.
APPEND oline TO otab.
oline-name = 'POSNO'.
APPEND oline TO otab.
oline-name = 'SOD_HK_DT'.
APPEND oline TO otab.
WHEN '3'.
ASSIGN COMPONENT 'SOD_HK_DT' OF STRUCTURE <dyn_wa> TO <fs_field1>.
ASSIGN COMPONENT 'POSNO' OF STRUCTURE <dyn_wa> TO <fs_field2>.
ASSIGN COMPONENT 'ORDNO' OF STRUCTURE <dyn_wa> TO <fs_field3>.
l_c_label1 = text-r01.
l_c_label2 = text-r03.
l_c_label3 = text-r02.
oline-name = 'SOD_HK_DT'.
APPEND oline TO otab.
oline-name = 'POSNO'.
APPEND oline TO otab.
oline-name = 'ORDNO'.
APPEND oline TO otab.
WHEN OTHERS.
ENDCASE.
ASSIGN COMPONENT 'OBJID' OF STRUCTURE <dyn_wa> TO <f1>.
ASSIGN COMPONENT 'KG_CURCY' OF STRUCTURE <dyn_wa> TO <f2>.
ASSIGN COMPONENT 'URIHYO_KG' OF STRUCTURE <dyn_wa> TO <f3>.
SORT u_itab_t0320 BY (otab).
LOOP AT u_itab_t0320 INTO <dyn_wa>.
at new <fs_field1>.
FORMAT COLOR 3. " yellow
WRITE: / l_c_label1,
<fs_field1>.
ENDAT.
AT NEW <fs_field2>.
FORMAT COLOR 6. " red
WRITE: /4 l_c_label2,
<fs_field2>.
ENDAT.
AT NEW <fs_field3>.
FORMAT COLOR 4. " blue
WRITE: /8 l_c_label3,
<fs_field3>.
ENDAT.
FORMAT COLOR OFF.
WRITE: /12 <f1>,
<f2>,
<f3>.
ENDLOOP.
ENDFORM. "fm_output