Report - Get Delivery and PO Details from Internal TU (EWM) - Type 2


*&---------------------------------------------------------------------*
*& Report ZAG_TU_DEL2
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zag_tu_del2.

*-> Selection Screen
PARAMETERSp_itu  TYPE /scwm/de_tu_num OBLIGATORY.

*-> Local Data Declarations
TYPESBEGIN OF lty_dlv_po,
         docno 
TYPE /scdl/dl_docno_int,
         po    
TYPE /scdl/dl_refdocno,
       
END OF lty_dlv_po.

DATAls_tu_sr_act_num   TYPE /scwm/s_tu_sr_act_num,
      lt_tu_dlv_temp     
TYPE /scwm/tt_bo_tu_dlv_no_sort,
      ls_excl_fd_data    
TYPE /scwm/dlv_query_excl_fd_str,
      ls_excl_prd_data   
TYPE /scwm/dlv_query_excl_str,
      ls_read_options    
TYPE /scwm/dlv_query_contr_str,
      ls_fd_read_options 
TYPE /scwm/dlv_query_contr_fd_str,
      lt_dlv_po          
TYPE STANDARD TABLE OF lty_dlv_po.

FIELD-SYMBOLS<fs_excl> TYPE any.

CONSTANTS lc_refdoccat_po TYPE /scdl/dl_refdoccat VALUE 'PO'.

*-> Get Shipping and Receiving Activity
SELECT tu_sr_act_num
  
UP TO ROWS
  
FROM /scwm/tu_dlv
  
INTO @DATA(lv_tu_sr_act_num)
 
WHERE tu_num @p_itu.
ENDSELECT.
IF sy-subrc 0.
*-> Get Instance - Shipping & Receiving Business Object Manager
  
TRY.
      
CALL METHOD /scwm/cl_sr_bom=>get_instance
        RECEIVING
          ro_bom 
DATA(lo_sr_bom).
    
CATCH /scwm/cx_sr_error.
      
RETURN.
  
ENDTRY.

  
IF lo_sr_bom IS BOUND.
*-> Prepare Key
    ls_tu_sr_act_num
-tu_num        p_itu.
    ls_tu_sr_act_num
-tu_sr_act_num lv_tu_sr_act_num.

*-> Get Business Object of Transportation Unit
    
TRY.
        
CALL METHOD lo_sr_bom->get_bo_tu_by_key
          
EXPORTING
            is_tu_sr_act_num 
ls_tu_sr_act_num
          RECEIVING
            ro_bo_tu         
DATA(lo_bo_tu).
      
CATCH /scwm/cx_sr_error.
        
RETURN.
    
ENDTRY.

    
IF lo_bo_tu IS BOUND.
*-> Fill EXPORTING parameters
      
DATA(lo_structdescr) = CAST cl_abap_structdescrcl_abap_datadescr=>describe_by_datals_excl_fd_data ) ).
      
DATA(lv_components) = lineslo_structdescr->components ).

      
DO lv_components TIMES.
        
ASSIGN COMPONENT sy-index OF STRUCTURE ls_excl_fd_data TO <fs_excl>.
        <fs_excl> 
abap_true.
      
ENDDO.

      ls_excl_prd_data
-item_all abap_true.

      ls_fd_read_options
-data_retrieval_only abap_true.

*-> Get TU Delivery Data
      
TRY.
          
CALL METHOD lo_bo_tu->get_tu_dlv_data
            
EXPORTING
              is_excl_fd_data    
ls_excl_fd_data
              is_excl_prd_data   
ls_excl_prd_data
              is_fd_read_options 
ls_fd_read_options
              iv_no_txt_item     
abap_true
            
IMPORTING
              et_prd_hdr         
DATA(lt_prd_hdr).
        
CATCH /scwm/cx_sr_error.
          
RETURN.
      
ENDTRY.
      
IF lt_prd_hdr IS NOT INITIAL.
        
LOOP AT lt_prd_hdr ASSIGNING FIELD-SYMBOL(<lfs_prd_hdr>).
          
APPEND INITIAL LINE TO lt_dlv_po ASSIGNING FIELD-SYMBOL(<lfs_dlv_po>).
          <lfs_dlv_po>
-docno <lfs_prd_hdr>-docno.
          
READ TABLE <lfs_prd_hdr>-refdoc ASSIGNING FIELD-SYMBOL(<lfs_refdoc>)
                                          
WITH KEY refdoccat lc_refdoccat_po.
          
IF sy-subrc 0.
            <lfs_dlv_po>
-po    <lfs_refdoc>-refdocno.
          
ENDIF.
        
ENDLOOP.
      
ENDIF." lt_prd_hdr NOT INITIAL
    
ENDIF"lo_bo_tu BOUND
  
ENDIF"lo_sr_bom BOUND
ENDIF"SELECT /SCWM/TU_DLV

END-OF-SELECTION.
  
IF lt_dlv_po IS NOT INITIAL.
    
TRY.
        
CALL METHOD cl_salv_table=>factory
          
IMPORTING
            r_salv_table 
DATA(lo_salv_table)
          
CHANGING
            t_table      
lt_dlv_po.
        
IF lo_salv_table IS BOUND.
          
CALL METHOD lo_salv_table->display.
        
ENDIF.
      
CATCH cx_salv_msg.
    
ENDTRY.
  
ENDIF"lt_dlv_po NOT INITIAL

Comments

Popular posts from this blog

EWM PPF Trigger the existing PPF Action through Custom Program

ABAP 7.5 - FILTER Statement

Useful Transaction Codes / Tools in OData ABAP Service / SAP UI5/ SAP Fiori