sábado, 4 de noviembre de 2017

BAPI_SHIPMENT_CREATE - VT01N

******************************************************************************** * INFORMACIÓN GENERAL - GENERAL INFORMATION ******************************************************************************** *^ Autor - Author : José Manrique Valderrama *^ Objetivo - Objetive : Creación de Documento de transporte (Shipment) - VT01N *^ Website : abapejemplos.blogspot.com ******************************************************************************** REPORT zjm_demo_shipment. PARAMETERS: p_tplst TYPE vttk-tplst OBLIGATORY, p_shtyp TYPE vttk-shtyp OBLIGATORY, p_vbeln TYPE lips-vbeln. DATA: gdt_item TYPE STANDARD TABLE OF bapishipmentitem, gdt_dlin TYPE STANDARD TABLE OF bapishipmentheaderdeadline, gdt_ret2 TYPE bapiret2_tab. DATA: gwa_header TYPE bapishipmentheader. FIELD-SYMBOLS: <fs_item> TYPE bapishipmentitem, <fs_dlin> TYPE bapishipmentheaderdeadline, <fs_ret2> TYPE bapiret2. DATA: gv_tknum TYPE vttk-tknum. START-OF-SELECTION. REFRESH: gdt_item, gdt_dlin, gdt_ret2. CLEAR: gwa_header, gv_tknum. "Cabecera del Documento de transporte gwa_header-shipment_type = p_shtyp. gwa_header-trans_plan_pt = p_tplst. "Se inicia en status Planificado "Se puede iniciar en otro status, se deben marcar todos los status previos gwa_header-status_plan = abap_true. "Se completa la fecha y hora de cada status APPEND INITIAL LINE TO gdt_dlin ASSIGNING <fs_dlin>. <fs_dlin>-time_type = 'HDRSTPLDT'. <fs_dlin>-time_stamp_utc = sy-datum && sy-uzeit. <fs_dlin>-time_zone = 'UTC'. *SAP-Note 531207 *TIME_TYPE = HDRSTPLDT --> Date/time of end of planning *TIME_TYPE = HDRSTCIPDT --> PLANNED date/time of check-in *TIME_TYPE = HDRSTCIADT --> ACTUAL date/time of check-in *TIME_TYPE = HDRSTLSPDT --> PLANNED date/time of loading start *TIME_TYPE = HDRSTLSADT --> ACTUAL date/time of loading start *TIME_TYPE = HDRSTLEPDT --> PLANNED date/time of loading end *TIME_TYPE = HDRSTLEADT --> ACTUAL date/time of loading end *TIME_TYPE = HDRSTCPDT --> PLANNED date/time of shipment completion *TIME_TYPE = HDRSTCADT --> ACTUAL date/time of shipment completion *TIME_TYPE = HDRSTSSPDT --> PLANNED date/time of shipment start *TIME_TYPE = HDRSTSSADT --> ACTUAL date/time of shipment start *TIME_TYPE = HDRSTSEPDT --> PLANNED date/time of shipment end *TIME_TYPE = HDRSTSEADT --> ACTUAL date/time of shipment end "Se pueden asignar las entregas, no es obligatorio. IF p_vbeln IS NOT INITIAL. APPEND INITIAL LINE TO gdt_item ASSIGNING . <fs_item>-delivery = p_vbeln. ENDIF. "Se ejecuta la BAPI CALL FUNCTION 'BAPI_SHIPMENT_CREATE' EXPORTING headerdata = gwa_header IMPORTING transport = gv_tknum TABLES headerdeadline = gdt_dlin itemdata = gdt_item return = gdt_ret2. "Si GV_TKNUM tiene un valor, se creó el transporte IF gv_tknum IS INITIAL. READ TABLE gdt_ret2 ASSIGNING <fs_ret2> WITH KEY type = 'E'. IF sy-subrc EQ 0. "Mensaje de la BAPI MESSAGE <fs_ret2>-message TYPE 'S' DISPLAY LIKE 'E'. ENDIF. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = abap_true. ENDIF.

No hay comentarios:

Publicar un comentario