赞
踩
调用BAPI:BAPI_SHIPMENT_CREATE创建装运单本身很简单,但是如果是第一次使用的话,可能会对抬头的一些日期感到困惑
BAPI_SHIPMENT_CREATE抬头日期字段处理代码:Include程序:LV56I_BAPIHEA,子程序:set_header_data
常量定义:Include程序LV56I_BAPITOP
- *- Global constants: deadline types
- CONSTANTS: BEGIN OF gc_time_type,
- stpldt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTPLDT',
- "Status planned
- stcipdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCIPDT',
- "Status checkin plan
- stpladt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCIADT',
- "Status checkin act
- stlspdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLSPDT',
- "Status load start plan
- stlsadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLSADT',
- "Status load start act
- stlepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLEPDT',
- "Status load end plan
- stleadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLEADT',
- "Status load end act
- stcpdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCPDT',
- "Status complete plan
- stcadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCADT',
- "Status copmlete act
- stsspdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSSPDT',
- "Status shipmnt start plan
- stssadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSSADT',
- "Status shipmnt start act
- stsepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSEPDT',
- "Status shipmnt end plan
- stseadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSEADT',
- "Status shipmnt end act
- tndepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDEPDT',
- "Tendering earliest pick
- tndlpdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDLPDT',
- "Tendering latest pick
- tndeddt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDEDDT',
- "Tendering earliest delivery
- tndlddt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDLDDT',
- "Tendering latest delivery
- lstpdt LIKE bapishipmentstagedeadline-time_type VALUE 'STLSTPDT',
- "Stage start plan
- lstadt LIKE bapishipmentstagedeadline-time_type VALUE 'STLSTADT',
- "Stage start act
- lenpdt LIKE bapishipmentstagedeadline-time_type VALUE 'STLENDPT',
- "Stage end plan
- lenadt LIKE bapishipmentstagedeadline-time_type VALUE 'STLENADT',
- "Stage end act
- END OF gc_time_type.
常量的使用
在Incldue程序LV56I_BAPIHEA的set_header_data子程序中可以找到日期对应具体的vttk的日期
- LOOP AT it_deadline_ext.
- CASE it_deadline_ext-time_type.
- WHEN gc_time_type-stpldt. "Status planned
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dtdis TIME cs_data_int-uzdis.
- WHEN gc_time_type-stcipdt. "Status checkin plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dpreg TIME cs_data_int-upreg.
- WHEN gc_time_type-stpladt. "Status checkin act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dareg TIME cs_data_int-uareg.
- WHEN gc_time_type-stlspdt. "Status load start plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dplbg TIME cs_data_int-uplbg.
- WHEN gc_time_type-stlsadt. "Status load start act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dalbg TIME cs_data_int-ualbg.
- WHEN gc_time_type-stlepdt. "Status load end plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dplen TIME cs_data_int-uplen.
- WHEN gc_time_type-stleadt. "Status load end act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dalen TIME cs_data_int-ualen.
- WHEN gc_time_type-stcpdt . "Status complete plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dpabf TIME cs_data_int-upabf.
- WHEN gc_time_type-stcadt . "Status copmlete act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dtabf TIME cs_data_int-uzabf.
- WHEN gc_time_type-stsspdt. "Status shipmnt start plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dptbg TIME cs_data_int-uptbg.
- WHEN gc_time_type-stssadt. "Status shipmnt start act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-datbg TIME cs_data_int-uatbg.
- WHEN gc_time_type-stsepdt. "Status shipmnt end plan
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-dpten TIME cs_data_int-upten.
- WHEN gc_time_type-stseadt. "Status shipmnt end act
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-daten TIME cs_data_int-uaten.
- WHEN gc_time_type-tndepdt. "Tendering earliest pick
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-tndr_erpd
- TIME cs_data_int-tndr_erpt.
- WHEN gc_time_type-tndlpdt. "Tendering latest pick
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-tndr_ltpd
- TIME cs_data_int-tndr_ltpt.
- WHEN gc_time_type-tndeddt. "Tendering earliest delivery
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-tndr_erdd
- TIME cs_data_int-tndr_erdt.
- WHEN gc_time_type-tndlddt. "Tendering latest delivery
- CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
- TIME ZONE it_deadline_ext-time_zone
- INTO DATE cs_data_int-tndr_ltdd
- TIME cs_data_int-tndr_ltdt.
- WHEN OTHERS.
- gf_flag_rollback = gc_true.
- IF it_deadline_ext-time_type IS INITIAL. "v_546602
- sy-msgid = 'VTBAPI' .
- sy-msgty = 'E' .
- sy-msgno = '013' .
- ELSE.
- sy-msgid = 'VTBAPI' .
- sy-msgty = 'E' .
- sy-msgno = '014' .
- sy-msgv1 = it_deadline_ext-time_type.
- ENDIF. "^_546602
- PERFORM append_protocol USING
- sy-msgid sy-msgty sy-msgno
- sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- clear: sy-msgid, sy-msgty, sy-msgno, sy-msgv1.
- ENDCASE.
- ENDLOOP.
传入日期的使用方法(代码片段)如下:
- IF pa_syori_h-etd IS NOT INITIAL. " ETD
- ls_headline-time_type = 'HDRSTCPDT'. "Planned date for shipment completion
- CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
- EXPORTING
- i_datlo = pa_syori_h-etd
- i_timlo = sy-timlo
- * I_TZONE = SY-ZONLO
- IMPORTING
- e_timestamp = ls_headline-time_stamp_utc.
- ls_headline-time_zone = 'UTC'.
- APPEND ls_headline TO lt_headline.
- CLEAR:ls_headline.
- ENDIF.
-
- IF pa_syori_h-eta IS NOT INITIAL." ETA
- ls_headline-time_type = 'HDRSTSSPDT'. "Planned date for end of shipment
- CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
- EXPORTING
- i_datlo = pa_syori_h-eta
- i_timlo = sy-timlo
- * I_TZONE = SY-ZONLO
- IMPORTING
- e_timestamp = ls_headline-time_stamp_utc.
- ls_headline-time_zone = 'UTC'.
- APPEND ls_headline TO lt_headline.
- CLEAR:ls_headline.
- ENDIF.
-
- IF pa_syori_h-dpreg IS NOT INITIAL." チェックイン予定日付
- ls_headline-time_type = 'HDRSTCIPDT'. "Planned date of check-in
- CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
- EXPORTING
- i_datlo = pa_syori_h-dpreg
- i_timlo = sy-timlo
- * I_TZONE = SY-ZONLO
- IMPORTING
- e_timestamp = ls_headline-time_stamp_utc.
- ls_headline-time_zone = 'UTC'.
- APPEND ls_headline TO lt_headline.
- CLEAR:ls_headline.
- ENDIF.
-
- IF pa_syori_h-tdlnr IS NOT INITIAL.
- * 仕入先マスタを見て、マスタに存在する場合のみセット
- CLEAR: lwk_mcode,
- lwk_lifnr.
- PERFORM alpha_input USING pa_syori_h-tdlnr
- CHANGING lwk_mcode. " 海貨業者
- SELECT SINGLE lifnr FROM lfa1 INTO lwk_lifnr WHERE lifnr = lwk_mcode.
- IF sy-subrc = 0.
- ls_header-service_agent_id = pa_syori_h-tdlnr. " 海貸業者
- ENDIF.
-
- ENDIF.
- CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
- EXPORTING
- headerdata = ls_header
- IMPORTING
- transport = lv_transport
- * SHIPMENTGUID =
- TABLES
- headerdeadline = lt_headline
- itemdata = lt_items
- * STAGEDATA =
- * STAGEDEADLINE =
- * ITEMONSTAGE =
- * ADDRESS =
- * hdunheader = lt_hdunheader
- * hdunitem = lt_hdunitem
- return = lt_return.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。