Tuesday, November 15, 2011

Open New Window Using ABAP


 While displaying a report , generally user wants to drill down by clicking one of the lines or cells to get more detailed information about related topic. Most common behavior to accomplish this task is displaying detailed information at the same window. However in some cases users need to display the detailed report in another window. They need to see both reports inside different windows. For this purpose check sample below.



DATA ls_params TYPE tpara,
       lt_params TYPE TABLE OF tpara.

ls_params-paramid 'BUK'.
ls_params-partext '0001'.
APPEND ls_params TO lt_params.

ls_params-paramid 'BLN'.
ls_params-partext '00000101'.
APPEND ls_params TO lt_params.

ls_params-paramid 'GJR'.
ls_params-partext '2011'.
APPEND ls_params TO lt_params.


CALL FUNCTION 'CC_CALL_TRANSACTION_NEW_TASK'
  STARTING NEW TASK 'FB03_TASK'
 
DESTINATION 'NONE'
   

EXPORTING
    transaction           'FB03'
    skip_first_screen     'X'
  TABLES
    paramtab              lt_params
  EXCEPTIONS
    communication_failure 97
    system_failure        98
    OTHERS                99.

IF sy-subrc
NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. 









Read Handling Unit Items

If you need to get the contents of a handling unit , this function will help you.

*** Data
  DATA lf_highest_level_hu TYPE  exidv ,
              lt_hu_header TYPE hum_hu_header_t WITH HEADER LINE,
              lt_hu_items TYPE hum_hu_item_t WITH HEADER LINE .

*** Get Items
  CALL FUNCTION 'HU_GET_ONE_HU_DB'
    EXPORTING
      if_hu_number        i_handling_unit
      if_all_levels       'X'  
" Get All Levels
      if_with_text        'X'
    IMPORTING
      ef_highest_level_hu lf_highest_level_hu
      et_hu_header        lt_hu_header[]
      et_hu_items         lt_hu_items[]
    EXCEPTIONS
      hu_not_found        1
      hu_locked           2
      fatal_error         3
      OTHERS              4.
 

*** Delete root HUs if you need only materials 
   DELETE lt_hu_items WHERE unvel IS NOT INITIAL.