Open nangnangchuai opened 5 years ago
*&---------------------------------------------------------------------*
*& Report ZISS011_LTT2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ziss011_ltt2 MESSAGE-ID zmes.
TABLES:disvariant ,vbak,rseumod,konv.
TYPE-POOLS sscr.
TYPE-POOLS slis.
TYPES:
BEGIN OF gts_alv_item,
state TYPE string , "処理ステータス
kunnr TYPE vbak-kunnr, "受注先
name1 TYPE adrc-name1, "受注先名称
auart TYPE vbak-auart, "販売伝票タイプ
vdatu TYPE vbak-vdatu, "指定納入期日
vbeln TYPE vbak-vbeln, "販売伝票
posnr TYPE vbap-posnr, "販売伝票明細
vbeln2 TYPE lips-vbeln, "出荷伝票
posnr2 TYPE lips-posnr, "出荷明細
matnr TYPE vbap-matnr, "品目コード
arktx TYPE vbap-arktx, "品目テキスト
werks TYPE lips-werks, "プラント
lgort TYPE lips-lgort, "保管場所
lfimg TYPE lips-lfimg, "出荷数量実績 (販売単位)
vrkme TYPE lips-vrkme, "販売単位
lfimg2 TYPE lips-lfimg, "出荷数量実績 (基本数量単位)
meins TYPE lips-meins, "基本数量単位
kwert TYPE konv-kwert, "金額
waers TYPE konv-waers, "通貨コード
cancel TYPE string, "出庫取消理由
message TYPE string, "メッセージ
END OF gts_alv_item,
BEGIN OF gts_alv_sort, "TB-『ALVソート情報』
kunnr TYPE vbak-kunnr, "受注先
auart TYPE vbak-auart, "販売伝票タイプ
vdatu TYPE vbak-vdatu, "指定納入期日
vbeln TYPE vbak-vbeln, "販売伝票
posnr TYPE vbap-posnr, "販売伝票明細
END OF gts_alv_sort,
BEGIN OF gts_vbak, "TB-『販売伝票データ』
vbeln TYPE vbak-vbeln, "購買伝票
ernam TYPE vbak-ernam, "オブジェクト登録者名
kunnr TYPE vbak-kunnr, "受注先
vkorg TYPE vbak-kunnr, "販売組織
auart TYPE vbak-auart, "販売伝票タイプ
vdatu TYPE vbak-vdatu, "指定納入期日
knumv TYPE vbak-knumv, "伝票条件番号
posnr TYPE vbap-posnr, "販売明細
matnr TYPE vbap-matnr, "品目コード
arktx TYPE vbap-arktx, "受注明細のテキスト (短)
END OF gts_vbak,
BEGIN OF gts_vbfa,
vbelv TYPE vbfa-vbelv, "先行販売管理伝票 (VBELV)
posnv TYPE vbfa-posnv, "販売管理伝票前明細(POSNV)
vbeln TYPE vbfa-vbeln, "後続の販売管理伝票(VBELN )
posnn TYPE vbfa-posnn, "販売管理伝票次明細(POSNN )
END OF gts_vbfa,
BEGIN OF gts_lips,
vbeln TYPE lips-vbeln, "出荷伝票
posnr TYPE lips-posnr, "出荷明細
werks TYPE lips-werks, "プラント
lgort TYPE lips-lgort, "保管場所
lfimg TYPE lips-lfimg, "出荷数量実績
vrkme TYPE lips-vrkme, "販売単位
umvkz TYPE lips-umvkz, "販売数量単位から基本数量,単位への変換係数の分子
umvkn TYPE lips-umvkn, "販売数量を在庫単位に換算する
meins TYPE lips-meins, "基本数量単位
wbsta TYPE vbup-wbsta, "在庫移動ステータス
END OF gts_lips,
BEGIN OF gts_konv,
knumv TYPE konv-knumv, "伝票条件番号(KNUMV)
kposn TYPE konv-kposn, "条件明細番号(KPOSN)
kwert TYPE konv-kwert, "条件金額(KWERT)
waers TYPE konv-waers, "通貨コード(WAERS)
END OF gts_konv,
BEGIN OF gts_vbpa,
kunnr TYPE vbpa-kunnr, "受注先(VBPA-KUNNR )
nmae1 TYPE adrc-name1, "名称 1(ADRC-NAME1 )
END OF gts_vbpa.
DATA: restrict TYPE sscr_restrict,
optlist TYPE sscr_opt_list,
ass TYPE sscr_ass,
gst_variant TYPE disvariant, "
gwk_calluser TYPE c.
DATA: gdt_vbak TYPE TABLE OF gts_vbak ,
gds_vbak TYPE gts_vbak .
DATA: gdt_vbfa TYPE TABLE OF gts_vbfa ,
gds_vbfa TYPE gts_vbfa .
DATA: gdt_lips TYPE TABLE OF gts_lips ,
gds_lips TYPE gts_lips .
DATA: gdt_lips_backup TYPE TABLE OF gts_lips ,
gds_lips_backup TYPE gts_lips .
DATA: gdt_konv TYPE TABLE OF gts_konv ,
gds_konv TYPE gts_konv .
DATA: gdt_konv_backup TYPE TABLE OF gts_konv ,
gds_konv_backup TYPE gts_konv .
DATA: gdt_vbpa TYPE TABLE OF gts_vbpa,
gds_vbpa TYPE gts_vbpa.
DATA: gdt_vbpa_backup TYPE TABLE OF gts_vbpa, "取得した名称 1を受注先名称として退避するWK-『受注先名称』.
gds_vbpa_backup TYPE gts_vbpa. " WK-『受注先名称』
DATA gst_vbfa TYPE TABLE OF gts_vbfa. "ST-『販売伝票フローデータ』
DATA gwa_vbfa TYPE gts_vbfa.
DATA gst_lips TYPE TABLE OF gts_lips. "ST-『出荷伝票データ』
DATA gwa_lips TYPE gts_lips.
DATA gdt_alv_item TYPE TABLE OF gts_alv_item.
DATA gds_alv_item TYPE gts_alv_item.
DATA gdt_alv_sort TYPE TABLE OF gts_alv_sort. "TB-『ALVソート情報』
DATA gds_alv_sort TYPE gts_alv_sort.
DATA v_lines TYPE i.
*DATA gdt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: gdt_fieldcat TYPE slis_t_fieldcat_alv ,
gds_fieldcat TYPE slis_fieldcat_alv ,
gds_layout TYPE slis_layout_alv .
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
PARAMETERS: rb1 RADIOBUTTON GROUP g1 DEFAULT 'X',"未出庫データ
rb2 RADIOBUTTON GROUP g1."出庫確認済みデータ
SELECTION-SCREEN END OF BLOCK bk1.
PARAMETERS : p_vkorg TYPE vbak-vkorg ."OBLIGATORY . "販売組織
SELECT-OPTIONS: s_kunnr FOR vbak-kunnr . "受注先
PARAMETERS : p_ernam TYPE vbak-ernam. "オブジェクト登録者名
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. "販売伝票
PARAMETERS : p_vari TYPE disvariant-variant. "表示バリアント
PARAMETERS : p_tbmax TYPE rseumod-tbmaxsel. "最大表示件数
INITIALIZATION.
CLEAR optlist.
CLEAR ass.
optlist-name = 'EQ'. "1-2-1.OPTIONの制限の設定
optlist-options-eq = 'X'.
optlist-options-bt = ''.
APPEND optlist TO restrict-opt_list_tab. "1-2-2.属性の制限の設定
ass-kind = 'S'.
ass-name = 's_kunnr'.
ass-sg_main = 'I'.
ass-op_main = 'EQ'.
APPEND ass TO restrict-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' "1-2-3.セレクトオプションの指定制限設定
EXPORTING
program = sy-cprog
restriction = restrict
EXCEPTIONS
too_late = 1
repeated = 2
selopt_without_options = 3
selopt_without_signs = 4
invalid_sign = 5
empty_option_list = 6
invalid_kind = 7
repeated_kind_a = 8
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"1-3. 販売組織のデフォルト値設定-########
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari. "2. バリアントの検索ヘルプの作成
PERFORM f4_variant.
AT SELECTION-SCREEN OUTPUT. "3. 選択画面表題の設定
AT SELECTION-SCREEN.
PERFORM frm_check. "4. 選択画面入力値チェック
START-OF-SELECTION.
PERFORM frm_get_data. "5. データ取得処理
PERFORM frm_edit_data. "6. データ編集処理
PERFORM frm_display_alv. "7. 一覧画面出力処理
*&---------------------------------------------------------------------*
*& Form F4_VARIANT
*&---------------------------------------------------------------------*
* 2. バリアントの検索ヘルプの作成
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_variant .
DATA: lst_variant TYPE disvariant, "
lwk_calluser TYPE c.
lst_variant-report = sy-cprog. "2-1.バリアント情報の設定
CALL FUNCTION 'REUSE_ALV_VARIANT_F4' "2-2.バリアント情報入力可能値の表示
EXPORTING
is_variant = lst_variant ""ST-『バリアント入力情報』
i_save = 'A'
IMPORTING
e_exit = lwk_calluser "WK-『コールユーザ』
es_variant = lst_variant "ST-『バリアント出力情報』
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0 OR lwk_calluser = 'X'.
EXIT.
ENDIF.
IF lwk_calluser = ''.
p_vari = lst_variant-variant.
ENDIF.
ENDFORM. " F4_VARIANT
*&---------------------------------------------------------------------*
*& Form FRM_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_check .
SELECT SINGLE COUNT(*) FROM tvko "4-1.販売組織の妥当性チェック
WHERE vkorg = p_vkorg.
IF sy-subrc <> 0.
MESSAGE e001(zmes).
LEAVE LIST-PROCESSING.
ENDIF.
SELECT SINGLE COUNT(*) FROM usr01 "4-2.オブジェクト登録者名の妥当性チェック
WHERE bname = p_ernam.
IF sy-subrc <> 0.
MESSAGE e002(zmes).
LEAVE LIST-PROCESSING.
ENDIF.
"4-3.バリアントの妥当性チェック
gst_variant-report = sy-cprog. "4-3-1.バリアント情報の設定
gst_variant-variant = p_vari.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = 'A' "4-3-2.バリアントの存在チェック
CHANGING
cs_variant = gst_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e003(zmes).
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " FRM_CHECK
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
IF p_ernam IS NOT INITIAL. "5-1.オブジェクト登録者名のRANGEテーブルの作成
RANGES gtb_ernam FOR vbak-ernam. "TB-『レンジテーブル情報』
DATA gts_ernam LIKE LINE OF gtb_ernam. "ST-『レンジテーブル』
CLEAR gts_ernam.
gts_ernam-sign = 'I'.
gts_ernam-option = 'EQ'.
gts_ernam-low = p_ernam.
APPEND gts_ernam TO gtb_ernam.
ENDIF.
* 5-2.販売伝票データの取得
SELECT
a~vbeln "購買伝票
a~ernam "オブジェクト登録者名
a~kunnr "受注先
a~vkorg "販売組織
a~auart "販売伝票タイプ
a~vdatu "指定納入期日
a~knumv "伝票条件番号
b~posnr "販売明細
b~matnr "品目コード
b~arktx "受注明細のテキスト (短)
INTO TABLE gdt_vbak
FROM vbak AS a "DB『販売伝票: ヘッダデータ』
INNER JOIN vbap AS b "DB『販売伝票: 明細データ』
ON a~vbeln = b~vbeln
* FOR ALL ENTRIES IN gtb_ernam
WHERE a~vbeln IN s_vbeln "販売伝票(VBAK-VBELN )
AND a~ernam IN gtb_ernam "オブジェクト登録者名(VBAK-ERNAM )
AND a~lifsk = space "出荷ブロック(伝票ヘッダ)(VBAK-LIFSK)
AND a~vkorg = p_vkorg "販売組織(VBAK-VKORG)
AND a~kunnr IN s_kunnr. "受注先(VBAK-KUNNR)
IF sy-subrc <> 0.
MESSAGE e004(zmes).
LEAVE LIST-PROCESSING.
ENDIF.
*SELECT b~vbeln b~posnr a~waerk a~erdat auart bstnk pernr kzwi1 kwmeng "5-3.販売伝票フローの取得
* INTO CORRESPONDING FIELDS OF TABLE ivbap
* FROM vbak AS a
* INNER JOIN vbap AS b
* ON a~vbeln = b~vbeln
* INNER JOIN vbpa AS c
* ON a~vbeln = c~vbeln
* AND c~parvw = 'VE'
* FOR ALL ENTRIES IN itab
* WHERE b~vbeln = itab-vgbel AND b~posnr = itab-vgpos.
* "5-3.販売伝票フローの取得
SELECT vbelv "先行販売管理伝票
posnv "販売管理伝票前明細
vbeln "後続の販売管理伝票
posnn "販売管理伝票次明細XX
INTO TABLE gdt_vbfa
FROM vbfa
FOR ALL ENTRIES IN gdt_vbak
WHERE vbelv = gdt_vbak-vbeln
AND posnv = gdt_vbak-posnr
AND posnv = 'J'.
IF sy-subrc <> 0.
MESSAGE e004(zmes).
ENDIF.
IF NOT gdt_vbak[] IS INITIAL. "5-3-1.重複レコード削除
* SORT gdt_vbak BY vbeln posnn ASCENDING.
* DELETE ADJACENT DUPLICATES FROM gdt_vbak COMPARING vbeln posnn.
ENDIF.
.
"5-4.販売伝票: 出荷伝票:明細データの取得
CHECK gdt_lips IS NOT INITIAL.
DATA ldt_temp_lips LIKE gdt_lips.
SORT ldt_temp_lips BY vbeln.
DELETE ADJACENT DUPLICATES FROM ldt_temp_lips COMPARING vbeln posnr.
SELECT
b~vbeln "出荷明細
b~posnr "プラント
b~werks "プラント
b~lgort "保管場所
b~lfimg "出荷数量実績
b~vrkme "販売単位
b~umvkz "販売数量単位から基本数量,単位への変換係数の分子
b~umvkn "販売数量を在庫単位に換算する
b~meins "基本数量単位
a~wbsta "在庫移動ステータス
INTO TABLE gdt_lips
FROM vbup AS a
INNER JOIN lips AS b
ON a~vbeln = b~vbeln
AND a~posnr = b~posnr
FOR ALL ENTRIES IN ldt_temp_lips
WHERE b~vbeln = ldt_temp_lips-vbeln
AND b~posnr = ldt_temp_lips-posnr
AND b~ernam = gtb_ernam.
IF sy-subrc <> 0.
MESSAGE e004(zmes).
ENDIF.
* 5-4-1.未出庫データ、出庫確認済みデータの選出
* 5-5.条件 (トランザクションデータ)の取得
CHECK gdt_vbak[] IS NOT INITIAL.
DATA ldt_temp_vbak LIKE gdt_vbak.
SORT ldt_temp_vbak BY vbeln.
DELETE ADJACENT DUPLICATES FROM ldt_temp_vbak COMPARING vbeln.
SELECT knumv "伝票条件番号
kposn "条件明細番号
kwert "条件金額
waers "通貨コード
INTO TABLE gdt_konv
FROM konv AS a
FOR ALL ENTRIES IN ldt_temp_vbak
WHERE a~knumv = ldt_temp_vbak-knumv
AND a~kposn = ldt_temp_vbak-posnr
AND a~kschl = 'ZPR0'.
*5-6.受注先名称の取得
CHECK gdt_vbak[] IS NOT INITIAL.
ldt_temp_vbak = gdt_vbak.
SORT ldt_temp_vbak BY vbeln posnr.
DELETE ADJACENT DUPLICATES FROM ldt_temp_vbak COMPARING vbeln posnr.
SELECT a~kunnr"受注先
b~name1"名称1
INTO TABLE gdt_vbpa
FROM vbpa AS a
INNER JOIN adrc AS b
ON a~adrnr = b~addrnumber
FOR ALL ENTRIES IN ldt_temp_vbak
WHERE a~vbeln = ldt_temp_vbak-vbeln
AND a~kunnr = ldt_temp_vbak-kunnr.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FRM_EDIT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_edit_data .
"6-1. 内部テーブル事前ソート処理
IF NOT gdt_vbfa[] IS INITIAL. "TB-『販売伝票フローデータ』
SORT gdt_vbfa BY vbelv posnv.
ENDIF.
IF NOT gdt_lips[] IS INITIAL. "TB-『出荷伝票データ』
SORT gdt_lips BY vbeln posnr.
ENDIF.
IF NOT gdt_konv[] IS INITIAL. "TB-『条件データ』
SORT gdt_konv BY knumv kposn.
ENDIF.
IF NOT gdt_vbpa[] IS INITIAL. "TB-『受注先名称データ』
SORT gdt_vbpa BY kunnr.
ENDIF.
* 6-2. 内部テーブル編集処理
*6-2-1. 販売伝票フローデータの読込処理
LOOP AT gdt_vbak INTO gds_vbak.
READ TABLE gdt_vbfa INTO gds_vbfa WITH KEY vbelv = gds_vbak-vbeln posnv = gds_vbak-posnr.
IF sy-subrc = 0 .
APPEND gds_vbfa TO gst_vbfa. "ST-『販売伝票フローデータ』
ENDIF.
CLEAR gds_vbfa.
ENDLOOP.
*6-2-2. 出荷伝票:明細データの読込処理
LOOP AT gst_vbfa INTO gwa_vbfa.
READ TABLE gdt_lips INTO gds_lips WITH KEY vbeln = gwa_vbfa-vbeln posnr = gwa_vbfa-posnn .
IF sy-subrc = 0 .
APPEND gds_lips TO gst_lips. "ST-『出荷伝票データ』
ENDIF.
CLEAR gds_lips.
ENDLOOP.
*
**6-2-3. 受注先名称データの読込処理
LOOP AT gdt_vbak INTO gds_vbak.
READ TABLE gdt_vbpa INTO gds_vbpa WITH KEY kunnr = gds_vbak-kunnr.
IF sy-subrc = 0.
gds_vbpa_backup-nmae1 = gds_vbpa-nmae1.
APPEND gds_vbpa_backup TO gdt_vbpa_backup.
ENDIF.
ENDLOOP.
**6-2-4. 条件データの読込処理
LOOP AT gdt_vbak INTO gds_vbak.
READ TABLE gdt_konv INTO gds_konv WITH KEY knumv = gds_vbak-knumv kposn = gds_vbak-posnr .
IF sy-subrc = 0.
gds_konv_backup-kwert = gds_konv-kwert. "条件金額、 通貨コードを退避する "
gds_konv_backup-waers = gds_konv-waers.
APPEND gds_konv_backup TO gdt_konv_backup.
ENDIF.
ENDLOOP.
*6-2-5. 出荷数量実績 (基本数量単位)編集処理
LOOP AT gdt_lips INTO gds_lips.
gds_lips_backup-lfimg = gds_lips-lfimg * gds_lips-umvkz / gds_lips-meins .
APPEND gds_lips_backup TO gdt_lips_backup.
ENDLOOP.
*6-3. ALV出力用内部テーブル編集処理を行う
LOOP AT gdt_alv_item INTO gds_alv_item.
*処理ステータス state
READ TABLE gdt_vbak INTO gds_vbak INDEX sy-tabix. "TB-『販売伝票データ』
IF sy-subrc = 0.
gds_alv_item-kunnr = gds_vbak-kunnr."受注先
gds_alv_item-auart = gds_vbak-auart ."販売伝票タイプ
gds_alv_item-vdatu = gds_vbak-vdatu."指定納入期日
gds_alv_item-vbeln = gds_vbak-vbeln."販売伝票
gds_alv_item-posnr = gds_vbak-posnr."販売伝票明細
gds_alv_item-matnr = gds_vbak-matnr. "品目コード
gds_alv_item-arktx = gds_vbak-arktx. "品目テキスト
ENDIF.
READ TABLE gst_lips INTO gwa_lips INDEX sy-tabix. "ST-『出荷伝票データ』
IF sy-subrc = 0.
gds_alv_item-vbeln2 = gwa_lips-vbeln."出荷伝票
gds_alv_item-posnr2 = gwa_lips-posnr."出荷明細
gds_alv_item-lgort = gwa_lips-lgort."保管場所
gds_alv_item-vrkme = gwa_lips-vrkme. "販売単位
gds_alv_item-meins = gwa_lips-meins. "基本数量単位
gds_alv_item-werks = gwa_lips-werks. "プラント
ENDIF.
gds_alv_item-name1 = gds_vbpa_backup-nmae1. "wk受注先名称
gds_alv_item-lfimg2 = gds_lips_backup-lfimg . "WK-『出荷数量実績 (基本数量単位)』
gds_alv_item-kwert = gds_konv_backup-kwert. "WK-『条件金額』
gds_alv_item-waers = gds_konv_backup-waers. "WK-『通貨コード』
gds_alv_item-cancel = space.
gds_alv_item-message = space.
APPEND gds_alv_item TO gdt_alv_item.
ENDLOOP.
*7. 一覧画面出力処理
*7-1. TB-『ALV出力データ』のソート処理
SORT gdt_alv_item BY kunnr auart vdatu vbeln posnr.
DESCRIBE TABLE gdt_alv_item LINES v_lines.
IF v_lines >= p_tbmax .
MESSAGE e006(zmes).
*・メッセージを出力し、一覧画面に遷移する (→メッセージ一覧№006)
*TB-『ALV出力データ』レコードがSC-『最大表示件数』以上のデータを削除する
DELETE gdt_alv_item INDEX p_tbmax.
ENDIF.
**7-2. フィールドカタログ作成の処理.
* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
* EXPORTING
* i_program_name = sy-cprog
* i_internal_tabname = gdt_alv_item
* i_inclname = sy-cprog
* CHANGING
* ct_fieldcat = gdt_fieldcat
* EXCEPTIONS
* inconsistent_interface = 1
* program_error = 2
* OTHERS = 3.
* IF sy-subrc <> 0.
* MESSAGE e0067(zmes).
* LEAVE LIST-PROCESSING.
* ENDIF.
ENDFORM. " FRM_EDIT_DATA
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_display_alv .
**7-3. フィールドカタログテーブル編集処理
*
PERFORM frm_fieldcat. "フィールドカタログの作成
PERFORM frm_layout.
PERFORM frm_alv_data_sort. "7-4-3. ALVソート設定処理
** PERFORM frm_events.
PERFORM frm_alv_display. "7-4-4. ALV出力処理
*
ENDFORM. " FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form FRM_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_fieldcat .
PERFORM frm_set_fieldcat USING 'state' '処理ステータス' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'kunnr' '受注先' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'name1' '受注先名称' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'auart' '販売伝票タイプ' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'vdatu' '指定納入期日' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'vbeln' '販売伝票' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'posnr' '販売伝票明細' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'vbeln2' '出荷伝票' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'posnr2' '出荷明細' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'matnr' '品目コード' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'arktx' '品目テキスト' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'werks' 'プラント' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'lgort' '保管場所' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'lfimg' '出荷数量実績 (販売単位)' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'vrkme' '販売単位' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'lfimg2' '出荷数量実績 (基本数量単位)' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'meins' '基本数量単位' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'kwert' '金額' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'waers' '通貨コード' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'cancel' '出庫取消理由' '' '' '' '' ''.
PERFORM frm_set_fieldcat USING 'message' 'メッセージ' '' '' '' '' ''.
ENDFORM. " FRM_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_1319 text
* -->P_1320 text
* -->P_1321 text
* -->P_1322 text
* -->P_1323 text
* -->P_1324 text
*----------------------------------------------------------------------*
FORM frm_set_fieldcat USING p_field "フィールド名前
p_name "出力フィールドテキスト
p_edit "編集可能設定値
p_qfield "フィールド
p_qtablename "テーブル名前
p_ref_field "参照フィールド名前
p_ref_tablename. "参照テーブル名前
DATA: ldf_col TYPE i.
gds_fieldcat-col_pos = ldf_col.
gds_fieldcat-fieldname = p_field.
gds_fieldcat-seltext_m = p_name.
gds_fieldcat-edit = p_edit.
gds_fieldcat-outputlen = 16.
gds_fieldcat-qfieldname = p_qfield.
gds_fieldcat-qtabname = p_qtablename.
gds_fieldcat-ref_fieldname = p_ref_field.
gds_fieldcat-ref_tabname = p_ref_tablename.
APPEND gds_fieldcat TO gdt_fieldcat.
ldf_col = ldf_col + 1.
CLEAR gds_fieldcat.
**********************1選択画面で「出庫確認済みデータ」が選択されている場合のみ表示する*********8
ENDFORM. " FRM_SET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_LAYOUT
*&---------------------------------------------------------------------*
* 7-4. ALV一覧画面出力処理
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_layout .
*7-4-1. レイアウト設定処理
gds_layout-box_fieldname = 'SEL'.
gds_layout-lights_fieldname = 'STATUS'.
*7-4-2. バリアント設定処理
gst_variant-report = sy-repid.
gst_variant-username = sy-uname.
gst_variant-variant = p_vari .
ENDFORM. " FRM_LAYOUT
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DATA_SORT
*&---------------------------------------------------------------------*
* 7-4-3. ALVソート設定処理
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_alv_data_sort .
*受注先、販売伝票タイプ、指定納入期日、販売伝票、販売伝票明細
* sort gdt_alv_item by kunnr auart vdatu vbeln posnr.
LOOP AT gdt_alv_item INTO gds_alv_item.
READ TABLE gdt_alv_sort INTO gds_alv_sort INDEX sy-tabix .
IF sy-subrc = 0.
gds_alv_sort-kunnr = gds_alv_item-kunnr."受注先
gds_alv_sort-auart = gds_alv_item-auart."販売伝票タイプ
gds_alv_sort-vdatu = gds_alv_item-vdatu."指定納入期日
gds_alv_sort-vbeln = gds_alv_item-vbeln."販売伝票
gds_alv_sort-posnr = gds_alv_item-posnr."販売伝票明細
ENDIF.
APPEND gds_alv_sort TO gdt_alv_sort.
ENDLOOP.
ENDFORM. " FRM_ALV_DATA_SORT
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
* 7-4-4. ALV出力処理
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_SET_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout = gds_layout
it_fieldcat = gdt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
it_sort = gdt_alv_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'A '
is_variant = gst_variant
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gdt_alv_item
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " FRM_ALV_DISPLAY
*7-5. ALVのステータス設定処理ルーチン