当前位置:   article > 正文

SAP VT01N创建Shipment Number

vt01n

调用BAPI:BAPI_SHIPMENT_CREATE创建装运单本身很简单,但是如果是第一次使用的话,可能会对抬头的一些日期感到困惑

BAPI_SHIPMENT_CREATE抬头日期字段处理代码:Include程序:LV56I_BAPIHEA,子程序:set_header_data

常量定义:Include程序LV56I_BAPITOP

  1. *- Global constants: deadline types
  2. CONSTANTS: BEGIN OF gc_time_type,
  3. stpldt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTPLDT',
  4. "Status planned
  5. stcipdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCIPDT',
  6. "Status checkin plan
  7. stpladt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCIADT',
  8. "Status checkin act
  9. stlspdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLSPDT',
  10. "Status load start plan
  11. stlsadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLSADT',
  12. "Status load start act
  13. stlepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLEPDT',
  14. "Status load end plan
  15. stleadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTLEADT',
  16. "Status load end act
  17. stcpdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCPDT',
  18. "Status complete plan
  19. stcadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTCADT',
  20. "Status copmlete act
  21. stsspdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSSPDT',
  22. "Status shipmnt start plan
  23. stssadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSSADT',
  24. "Status shipmnt start act
  25. stsepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSEPDT',
  26. "Status shipmnt end plan
  27. stseadt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRSTSEADT',
  28. "Status shipmnt end act
  29. tndepdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDEPDT',
  30. "Tendering earliest pick
  31. tndlpdt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDLPDT',
  32. "Tendering latest pick
  33. tndeddt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDEDDT',
  34. "Tendering earliest delivery
  35. tndlddt LIKE bapishipmentheaderdeadline-time_type VALUE 'HDRTNDLDDT',
  36. "Tendering latest delivery
  37. lstpdt LIKE bapishipmentstagedeadline-time_type VALUE 'STLSTPDT',
  38. "Stage start plan
  39. lstadt LIKE bapishipmentstagedeadline-time_type VALUE 'STLSTADT',
  40. "Stage start act
  41. lenpdt LIKE bapishipmentstagedeadline-time_type VALUE 'STLENDPT',
  42. "Stage end plan
  43. lenadt LIKE bapishipmentstagedeadline-time_type VALUE 'STLENADT',
  44. "Stage end act
  45. END OF gc_time_type.

 常量的使用

在Incldue程序LV56I_BAPIHEA的set_header_data子程序中可以找到日期对应具体的vttk的日期

  1. LOOP AT it_deadline_ext.
  2. CASE it_deadline_ext-time_type.
  3. WHEN gc_time_type-stpldt. "Status planned
  4. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  5. TIME ZONE it_deadline_ext-time_zone
  6. INTO DATE cs_data_int-dtdis TIME cs_data_int-uzdis.
  7. WHEN gc_time_type-stcipdt. "Status checkin plan
  8. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  9. TIME ZONE it_deadline_ext-time_zone
  10. INTO DATE cs_data_int-dpreg TIME cs_data_int-upreg.
  11. WHEN gc_time_type-stpladt. "Status checkin act
  12. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  13. TIME ZONE it_deadline_ext-time_zone
  14. INTO DATE cs_data_int-dareg TIME cs_data_int-uareg.
  15. WHEN gc_time_type-stlspdt. "Status load start plan
  16. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  17. TIME ZONE it_deadline_ext-time_zone
  18. INTO DATE cs_data_int-dplbg TIME cs_data_int-uplbg.
  19. WHEN gc_time_type-stlsadt. "Status load start act
  20. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  21. TIME ZONE it_deadline_ext-time_zone
  22. INTO DATE cs_data_int-dalbg TIME cs_data_int-ualbg.
  23. WHEN gc_time_type-stlepdt. "Status load end plan
  24. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  25. TIME ZONE it_deadline_ext-time_zone
  26. INTO DATE cs_data_int-dplen TIME cs_data_int-uplen.
  27. WHEN gc_time_type-stleadt. "Status load end act
  28. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  29. TIME ZONE it_deadline_ext-time_zone
  30. INTO DATE cs_data_int-dalen TIME cs_data_int-ualen.
  31. WHEN gc_time_type-stcpdt . "Status complete plan
  32. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  33. TIME ZONE it_deadline_ext-time_zone
  34. INTO DATE cs_data_int-dpabf TIME cs_data_int-upabf.
  35. WHEN gc_time_type-stcadt . "Status copmlete act
  36. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  37. TIME ZONE it_deadline_ext-time_zone
  38. INTO DATE cs_data_int-dtabf TIME cs_data_int-uzabf.
  39. WHEN gc_time_type-stsspdt. "Status shipmnt start plan
  40. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  41. TIME ZONE it_deadline_ext-time_zone
  42. INTO DATE cs_data_int-dptbg TIME cs_data_int-uptbg.
  43. WHEN gc_time_type-stssadt. "Status shipmnt start act
  44. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  45. TIME ZONE it_deadline_ext-time_zone
  46. INTO DATE cs_data_int-datbg TIME cs_data_int-uatbg.
  47. WHEN gc_time_type-stsepdt. "Status shipmnt end plan
  48. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  49. TIME ZONE it_deadline_ext-time_zone
  50. INTO DATE cs_data_int-dpten TIME cs_data_int-upten.
  51. WHEN gc_time_type-stseadt. "Status shipmnt end act
  52. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  53. TIME ZONE it_deadline_ext-time_zone
  54. INTO DATE cs_data_int-daten TIME cs_data_int-uaten.
  55. WHEN gc_time_type-tndepdt. "Tendering earliest pick
  56. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  57. TIME ZONE it_deadline_ext-time_zone
  58. INTO DATE cs_data_int-tndr_erpd
  59. TIME cs_data_int-tndr_erpt.
  60. WHEN gc_time_type-tndlpdt. "Tendering latest pick
  61. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  62. TIME ZONE it_deadline_ext-time_zone
  63. INTO DATE cs_data_int-tndr_ltpd
  64. TIME cs_data_int-tndr_ltpt.
  65. WHEN gc_time_type-tndeddt. "Tendering earliest delivery
  66. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  67. TIME ZONE it_deadline_ext-time_zone
  68. INTO DATE cs_data_int-tndr_erdd
  69. TIME cs_data_int-tndr_erdt.
  70. WHEN gc_time_type-tndlddt. "Tendering latest delivery
  71. CONVERT TIME STAMP it_deadline_ext-time_stamp_utc
  72. TIME ZONE it_deadline_ext-time_zone
  73. INTO DATE cs_data_int-tndr_ltdd
  74. TIME cs_data_int-tndr_ltdt.
  75. WHEN OTHERS.
  76. gf_flag_rollback = gc_true.
  77. IF it_deadline_ext-time_type IS INITIAL. "v_546602
  78. sy-msgid = 'VTBAPI' .
  79. sy-msgty = 'E' .
  80. sy-msgno = '013' .
  81. ELSE.
  82. sy-msgid = 'VTBAPI' .
  83. sy-msgty = 'E' .
  84. sy-msgno = '014' .
  85. sy-msgv1 = it_deadline_ext-time_type.
  86. ENDIF. "^_546602
  87. PERFORM append_protocol USING
  88. sy-msgid sy-msgty sy-msgno
  89. sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  90. clear: sy-msgid, sy-msgty, sy-msgno, sy-msgv1.
  91. ENDCASE.
  92. ENDLOOP.

传入日期的使用方法(代码片段)如下:

  1. IF pa_syori_h-etd IS NOT INITIAL. " ETD
  2. ls_headline-time_type = 'HDRSTCPDT'. "Planned date for shipment completion
  3. CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
  4. EXPORTING
  5. i_datlo = pa_syori_h-etd
  6. i_timlo = sy-timlo
  7. * I_TZONE = SY-ZONLO
  8. IMPORTING
  9. e_timestamp = ls_headline-time_stamp_utc.
  10. ls_headline-time_zone = 'UTC'.
  11. APPEND ls_headline TO lt_headline.
  12. CLEAR:ls_headline.
  13. ENDIF.
  14. IF pa_syori_h-eta IS NOT INITIAL." ETA
  15. ls_headline-time_type = 'HDRSTSSPDT'. "Planned date for end of shipment
  16. CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
  17. EXPORTING
  18. i_datlo = pa_syori_h-eta
  19. i_timlo = sy-timlo
  20. * I_TZONE = SY-ZONLO
  21. IMPORTING
  22. e_timestamp = ls_headline-time_stamp_utc.
  23. ls_headline-time_zone = 'UTC'.
  24. APPEND ls_headline TO lt_headline.
  25. CLEAR:ls_headline.
  26. ENDIF.
  27. IF pa_syori_h-dpreg IS NOT INITIAL." チェックイン予定日付
  28. ls_headline-time_type = 'HDRSTCIPDT'. "Planned date of check-in
  29. CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
  30. EXPORTING
  31. i_datlo = pa_syori_h-dpreg
  32. i_timlo = sy-timlo
  33. * I_TZONE = SY-ZONLO
  34. IMPORTING
  35. e_timestamp = ls_headline-time_stamp_utc.
  36. ls_headline-time_zone = 'UTC'.
  37. APPEND ls_headline TO lt_headline.
  38. CLEAR:ls_headline.
  39. ENDIF.
  40. IF pa_syori_h-tdlnr IS NOT INITIAL.
  41. * 仕入先マスタを見て、マスタに存在する場合のみセット
  42. CLEAR: lwk_mcode,
  43. lwk_lifnr.
  44. PERFORM alpha_input USING pa_syori_h-tdlnr
  45. CHANGING lwk_mcode. " 海貨業者
  46. SELECT SINGLE lifnr FROM lfa1 INTO lwk_lifnr WHERE lifnr = lwk_mcode.
  47. IF sy-subrc = 0.
  48. ls_header-service_agent_id = pa_syori_h-tdlnr. " 海貸業者
  49. ENDIF.
  50. ENDIF.
  1. CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
  2. EXPORTING
  3. headerdata = ls_header
  4. IMPORTING
  5. transport = lv_transport
  6. * SHIPMENTGUID =
  7. TABLES
  8. headerdeadline = lt_headline
  9. itemdata = lt_items
  10. * STAGEDATA =
  11. * STAGEDEADLINE =
  12. * ITEMONSTAGE =
  13. * ADDRESS =
  14. * hdunheader = lt_hdunheader
  15. * hdunitem = lt_hdunitem
  16. return = lt_return.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/525875
推荐阅读
相关标签
  

闽ICP备14008679号