FUNCTION ZSDF_CD_GERA_REMESSA_VL10B.
*"----------------------------------------------------------------------
*"*"Interface local:
*" IMPORTING
*" REFERENCE(I_EBELN) TYPE EKKO-EBELN
*" REFERENCE(I_VSTEL) TYPE LIKP-VSTEL DEFAULT SPACE
*" EXPORTING
*" REFERENCE(E_VBELN) TYPE LIKP-VBELN
*" TABLES
*" IT_RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
CONSTANTS: cl_list_type_indx VALUE '1', "Show Index data
cl_list_type_item VALUE '2', "show Item data
cl_list_type_sche VALUE '3'. "show Schedulelines
FIELD-SYMBOLS: <fs_head> TYPE table,
<fs_item> TYPE table,
<fs_head_name>,
<fs_item_name>.
DATA: l_layout TYPE shp_vl10_szenario,
l_subrc TYPE sy-subrc,
l_tabix TYPE sy-tabix,
l_role,
l_frame.
DATA: lt_ebeln TYPE TABLE OF shp_ebeln_range,
lt_vstel TYPE TABLE OF shp_vstel_range,
lt_delivery TYPE shp_vl10_delivery,
lt_vbls TYPE TABLE OF vbls WITH HEADER LINE,
lt_table TYPE shp_vl10_postab_t,
lt_head TYPE shp_vl10_postab_t,
lt_item TYPE shp_vl10_postab_t,
lt_head2 TYPE shp_vl10_indx_t,
lt_item2 TYPE shp_vl10_indx_t,
lt_vbsk_all TYPE shp_vbsk_t.
DATA: lw_profilname TYPE shp_vl10_list_profilname,
lw_t186v TYPE t186v,
lw_vbsk TYPE vbsk,
lw_list_profil TYPE shp_vl10_list_profil,
lw_parameters TYPE shp_vl10_parameters,
lw_select_options TYPE shp_vl10_select_options,
lw_ebeln TYPE shp_ebeln_range,
lw_vstel TYPE shp_vstel_range,
lw_enqueue TYPE shp_vl10_package_t,
lw_delivery TYPE shp_vl10_delivery,
lw_selfield TYPE slis_selfield,
lw_table LIKE LINE OF lt_table.
CLEAR lw_ebeln.
lw_ebeln-sign = 'I'.
lw_ebeln-option = 'EQ'.
lw_ebeln-low = i_ebeln.
COLLECT lw_ebeln INTO lt_ebeln.
lw_select_options-ebeln = lt_ebeln[].
lw_select_options-vstel = lt_vstel[].
l_layout = '0002'. "Purchase order
lw_profilname = '0002'.
PERFORM profil_data_complete(saplv50r_pre) USING l_layout
lw_profilname
CHANGING lw_t186v
lw_list_profil.
lw_list_profil-ampel = SPACE.
* Do not display VL10B output.
SEARCH lw_list_profil-fcodes FOR 'DISPLAY'.
IF sy-subrc = 0.
DELETE lw_list_profil-fcodes INDEX sy-tabix.
ENDIF.
lw_parameters-vstel = i_vstel.
CALL FUNCTION 'SHP_EXTENDED_DUE_LIST'
EXPORTING
ix_list_profil = lw_list_profil
ix_parameters = lw_parameters
ix_select_options = lw_select_options
IMPORTING
ex_delivery = lt_delivery
TABLES
et_postab = lt_table
EXCEPTIONS
OTHERS = 1.
* Note: lt_table has all the data that we see in VL10B output due list.
************Create Delivery...
CASE lw_list_profil-list_type.
WHEN cl_list_type_indx.
ASSIGN lt_head2[] TO <fs_head>.
ASSIGN lt_item2[] TO <fs_item>.
WHEN cl_list_type_item.
ASSIGN lt_head[] TO <fs_head>.
ASSIGN lt_item[] TO <fs_item>.
WHEN OTHERS.
PERFORM userexit_prepare_assign_tabs(saplv50r_view)
USING lw_list_profil
CHANGING <fs_head_name>
<fs_item_name>.
ASSIGN (<fs_head_name>) TO <fs_head>.
ASSIGN (<fs_item_name>) TO <fs_item>.
ENDCASE.
* --> Marco o item p/ processar
lw_table-selkz = 'X'.
MODIFY lt_table FROM lw_table TRANSPORTING selkz
WHERE selkz = space.
* Regra de cálculo o mesmo da tela da VL10B
lw_list_profil-ampel = SPACE.
lw_list_profil-ledat_high = sy-datum + 30.
PERFORM fcode_samd(saplv50r_view) CHANGING lw_enqueue
lw_list_profil
lw_selfield
lt_vbsk_all
lt_table
<fs_head>
<fs_item>
lw_delivery "created(sel.)
l_subrc.
lt_vbls[] = lw_delivery-vbls.
READ TABLE lt_vbls INDEX 1.
IF ( sy-subrc IS INITIAL ) AND ( NOT lt_vbls-vbeln_lif IS INITIAL ).
e_vbeln = lt_vbls-vbeln_lif.
SET PARAMETER ID 'VL' FIELD e_vbeln.
ELSE.
CLEAR lw_vbsk.
READ TABLE lt_vbsk_all INTO lw_vbsk INDEX 1.
PERFORM processa_erro TABLES it_return
USING lw_vbsk-sammg.
ENDIF.
ENDFUNCTION.
====================== NOVO 2022 =====================
BAPI_OUTB_DELIVERY_CREATE_STO