Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

display error messages for each material

Former Member
0 Likes
1,013

Hi All,

I am using a BAPI which gives errors in return table.I am executing this BAPI for several materials in a LOOP.I need to display the error messages for each of these materials as shown below:

Material 1:

error1

error2

Material 2:

error 1

error 2.

What is the best way to display this?Also plz let me know how to use REUSE_ALV_HIERSEQ_LIST_DISPLAY?

Thanks,

Rakesh.

1 ACCEPTED SOLUTION
Read only

gopi_narendra
Active Contributor
0 Likes
956

I did the same thing in the below code, go thru it and check it.

* calling the BAPI to update the Asset Master AS02
  loop at it_final into is_final.
 
* If updating of floor area only
    if p_farea = 'X'.
* passing new area value to the BAPI
      is_realestate-area     = is_final-grufl.
      is_realestatex-area    = 'X'.
 
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                realestate  = is_realestate
                realestatex = is_realestatex
           importing
                return      = it_return.
 
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-grufl_n = is_final-grufl.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-grufl_n = is_realestate-area.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
 
    endif.
 
* If updating of lease commencement date only
    if p_ldate = 'X'.
* Passing new lease start date value to the BAPI
      is_leasing-start_date  = is_final-leabg.
      is_leasingx-start_date = 'X'.
 
* Call the BAPI to change the Asset Master
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                leasing     = is_leasing
                leasingx    = is_leasingx
           importing
                return      = it_return.
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
 
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-leabg_n = is_final-leabg.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-leabg_n = is_leasing-start_date.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
    endif.
 
    clear : is_final, is_realestate, is_leasing,
            it_return, flag , is_output.
  endloop.
* Display the report out with old and new values
  PERFORM output_report.
*&---------------------------------------------------------------------*
*&      Form  output_report
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
*FORM output_report.
*
*  DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*         is_layout TYPE slis_layout_alv.
** Sub routine for filling the field catalog
*  IF it_fieldcat[] IS INITIAL.
*    PERFORM field_fill USING it_fieldcat.
*  ENDIF.
*
** Sub routine to set the layout
*  PERFORM set_layout USING is_layout.
*
** Function module to display the data in ALV format
*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*       EXPORTING
*            i_callback_program = l_repid
*            it_fieldcat        = it_fieldcat
*            is_layout          = is_layout
*       TABLES
*            t_outtab           = it_output
*       EXCEPTIONS
*            program_error      = 1
*            OTHERS             = 2.
*  IF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*  ENDIF.
*ENDFORM.                    " output_report
*&---------------------------------------------------------------------*
*&      Form  field_fill
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_FIELDCAT  text
*----------------------------------------------------------------------*
*FORM field_fill USING pt_fieldcat TYPE slis_t_fieldcat_alv.
*  DATA : ls_fieldcat TYPE slis_fieldcat_alv,
*         pos TYPE i VALUE 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'C_ICON'.
*  ls_fieldcat-seltext_m     = 'Change Status'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'BUKRS'.
*  ls_fieldcat-ref_fieldname = 'BUKRS'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN1'.
*  ls_fieldcat-ref_fieldname = 'ANLN1'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN2'.
*  ls_fieldcat-ref_fieldname = 'ANLN2'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  IF p_farea = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL'.
*    ls_fieldcat-ref_fieldname = 'GRUFL'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL_N'.
*    ls_fieldcat-seltext_l     = 'New Floor Area'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  IF p_ldate = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG'.
*    ls_fieldcat-ref_fieldname = 'LEABG'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG_N'.
*    ls_fieldcat-seltext_l     = 'New Lease St.Date'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'MESSAGE'.
*  ls_fieldcat-seltext_l     = 'Status Message'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*ENDFORM.                    " field_fill

Regards

Gopi

I did the same thing in the below code, go thru it and check it.

* calling the BAPI to update the Asset Master AS02
  loop at it_final into is_final.
 
* If updating of floor area only
    if p_farea = 'X'.
* passing new area value to the BAPI
      is_realestate-area     = is_final-grufl.
      is_realestatex-area    = 'X'.
 
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                realestate  = is_realestate
                realestatex = is_realestatex
           importing
                return      = it_return.
 
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-grufl_n = is_final-grufl.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-grufl_n = is_realestate-area.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
 
    endif.
 
* If updating of lease commencement date only
    if p_ldate = 'X'.
* Passing new lease start date value to the BAPI
      is_leasing-start_date  = is_final-leabg.
      is_leasingx-start_date = 'X'.
 
* Call the BAPI to change the Asset Master
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                leasing     = is_leasing
                leasingx    = is_leasingx
           importing
                return      = it_return.
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
 
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-leabg_n = is_final-leabg.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-leabg_n = is_leasing-start_date.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
    endif.
 
    clear : is_final, is_realestate, is_leasing,
            it_return, flag , is_output.
  endloop.
* Display the report out with old and new values
  PERFORM output_report.
*&---------------------------------------------------------------------*
*&      Form  output_report
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
*FORM output_report.
*
*  DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*         is_layout TYPE slis_layout_alv.
** Sub routine for filling the field catalog
*  IF it_fieldcat[] IS INITIAL.
*    PERFORM field_fill USING it_fieldcat.
*  ENDIF.
*
** Sub routine to set the layout
*  PERFORM set_layout USING is_layout.
*
** Function module to display the data in ALV format
*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*       EXPORTING
*            i_callback_program = l_repid
*            it_fieldcat        = it_fieldcat
*            is_layout          = is_layout
*       TABLES
*            t_outtab           = it_output
*       EXCEPTIONS
*            program_error      = 1
*            OTHERS             = 2.
*  IF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*  ENDIF.
*ENDFORM.                    " output_report
*&---------------------------------------------------------------------*
*&      Form  field_fill
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_FIELDCAT  text
*----------------------------------------------------------------------*
*FORM field_fill USING pt_fieldcat TYPE slis_t_fieldcat_alv.
*  DATA : ls_fieldcat TYPE slis_fieldcat_alv,
*         pos TYPE i VALUE 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'C_ICON'.
*  ls_fieldcat-seltext_m     = 'Change Status'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'BUKRS'.
*  ls_fieldcat-ref_fieldname = 'BUKRS'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN1'.
*  ls_fieldcat-ref_fieldname = 'ANLN1'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN2'.
*  ls_fieldcat-ref_fieldname = 'ANLN2'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  IF p_farea = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL'.
*    ls_fieldcat-ref_fieldname = 'GRUFL'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL_N'.
*    ls_fieldcat-seltext_l     = 'New Floor Area'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  IF p_ldate = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG'.
*    ls_fieldcat-ref_fieldname = 'LEABG'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG_N'.
*    ls_fieldcat-seltext_l     = 'New Lease St.Date'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'MESSAGE'.
*  ls_fieldcat-seltext_l     = 'Status Message'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*ENDFORM.                    " field_fill

Regards

Gopi

3 REPLIES 3
Read only

Former Member
0 Likes
956

hI,

bY CALL FUNCTION 'MESSAGE_TEXT_BUILD' you can disply the error msgs.

Check this example for using the FM..

TYPE-POOLS: slis.

DATA: BEGIN OF itab OCCURS 0,

vbeln TYPE vbeln,

expand,

END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

vbeln TYPE vbeln,

posnr TYPE posnr,

matnr TYPE matnr,

netpr TYPE netpr,

END OF itab1.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'VBELN'.

s_fieldcatalog-outputlen = '12'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'VBELN'.

s_fieldcatalog-outputlen = '12'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'POSNR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'POSNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'MATNR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'MATNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'NETPR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'NETPR'.

s_fieldcatalog-do_sum = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

DATA: s_layout TYPE slis_layout_alv.

s_layout-subtotals_text = 'SUBTOTAL TEXT'.

s_layout-key_hotspot = 'X'.

s_layout-expand_fieldname = 'EXPAND'.

SELECT vbeln UP TO 100 ROWS

FROM

vbak

INTO TABLE itab.

IF NOT itab[] IS INITIAL.

SELECT vbeln posnr matnr netpr

FROM vbap

INTO TABLE itab1

FOR ALL ENTRIES IN itab

WHERE vbeln = itab-vbeln.

ENDIF.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA: s_keyinfo TYPE slis_keyinfo_alv.

s_keyinfo-header01 = 'VBELN'.

s_keyinfo-item01 = 'VBELN'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = s_layout

it_fieldcat = t_fieldcatalog

i_tabname_header = 'ITAB'

i_tabname_item = 'ITAB1'

is_keyinfo = s_keyinfo

TABLES

t_outtab_header = itab

t_outtab_item = itab1

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

<b>Reward points</b>

Regards

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
956

Hi,

You can just create a screen(Model dialog) and then use WRITE statement to display the error. Alos use Supress dialog to supres the screen and goto the LIST directly.

Just loop through your list of messages and write them on to a screen.

Regards,

Sesh

Read only

gopi_narendra
Active Contributor
0 Likes
957

I did the same thing in the below code, go thru it and check it.

* calling the BAPI to update the Asset Master AS02
  loop at it_final into is_final.
 
* If updating of floor area only
    if p_farea = 'X'.
* passing new area value to the BAPI
      is_realestate-area     = is_final-grufl.
      is_realestatex-area    = 'X'.
 
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                realestate  = is_realestate
                realestatex = is_realestatex
           importing
                return      = it_return.
 
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-grufl_n = is_final-grufl.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-grufl_n = is_realestate-area.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting grufl_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
 
    endif.
 
* If updating of lease commencement date only
    if p_ldate = 'X'.
* Passing new lease start date value to the BAPI
      is_leasing-start_date  = is_final-leabg.
      is_leasingx-start_date = 'X'.
 
* Call the BAPI to change the Asset Master
      call function 'BAPI_FIXEDASSET_CHANGE'
           exporting
                companycode = is_final-bukrs
                asset       = is_final-anln1
                subnumber   = is_final-anln2
                leasing     = is_leasing
                leasingx    = is_leasingx
           importing
                return      = it_return.
* If Asset Master is changed with out any errors
      read table it_return with key type = 'E'.
      if sy-subrc = 0.
        flag = ' '.
      else.
        flag = 'X'.
* Call the COMMIT BAPI
        call function 'BAPI_TRANSACTION_COMMIT'
             exporting
                  wait = 'X'.
        wait up to 2 seconds.
      endif.
 
* If the Asset Master is changed with out any errors
      if flag = 'X'.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_green.
          is_output-leabg_n = is_final-leabg.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      elseif flag = ' '.
        read table it_output into is_output with key
                                  bukrs = is_final-bukrs
                                  anln1 = is_final-anln1
                                  anln2 = is_final-anln2
                                  binary search.
        if sy-subrc = 0.
*          is_output-c_icon  = c_red.
          is_output-leabg_n = is_leasing-start_date.
          is_output-message = it_return-message.
* Modify the output internal table with the changed new values
          modify it_output from is_output
                           transporting leabg_n message
                           where bukrs = is_output-bukrs
                             and anln1 = is_output-anln1
                             and anln2 = is_output-anln2.
        endif.
      endif.
    endif.
 
    clear : is_final, is_realestate, is_leasing,
            it_return, flag , is_output.
  endloop.
* Display the report out with old and new values
  PERFORM output_report.
*&---------------------------------------------------------------------*
*&      Form  output_report
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
*FORM output_report.
*
*  DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
*         is_layout TYPE slis_layout_alv.
** Sub routine for filling the field catalog
*  IF it_fieldcat[] IS INITIAL.
*    PERFORM field_fill USING it_fieldcat.
*  ENDIF.
*
** Sub routine to set the layout
*  PERFORM set_layout USING is_layout.
*
** Function module to display the data in ALV format
*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*       EXPORTING
*            i_callback_program = l_repid
*            it_fieldcat        = it_fieldcat
*            is_layout          = is_layout
*       TABLES
*            t_outtab           = it_output
*       EXCEPTIONS
*            program_error      = 1
*            OTHERS             = 2.
*  IF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*  ENDIF.
*ENDFORM.                    " output_report
*&---------------------------------------------------------------------*
*&      Form  field_fill
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_IT_FIELDCAT  text
*----------------------------------------------------------------------*
*FORM field_fill USING pt_fieldcat TYPE slis_t_fieldcat_alv.
*  DATA : ls_fieldcat TYPE slis_fieldcat_alv,
*         pos TYPE i VALUE 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'C_ICON'.
*  ls_fieldcat-seltext_m     = 'Change Status'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'BUKRS'.
*  ls_fieldcat-ref_fieldname = 'BUKRS'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN1'.
*  ls_fieldcat-ref_fieldname = 'ANLN1'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'ANLN2'.
*  ls_fieldcat-ref_fieldname = 'ANLN2'.
*  ls_fieldcat-ref_tabname   = 'ANLA'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*  IF p_farea = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL'.
*    ls_fieldcat-ref_fieldname = 'GRUFL'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'GRUFL_N'.
*    ls_fieldcat-seltext_l     = 'New Floor Area'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  IF p_ldate = 'X'.
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG'.
*    ls_fieldcat-ref_fieldname = 'LEABG'.
*    ls_fieldcat-ref_tabname   = 'ANLA'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*
*    ls_fieldcat-col_pos       = pos.
*    ls_fieldcat-fieldname     = 'LEABG_N'.
*    ls_fieldcat-seltext_l     = 'New Lease St.Date'.
*    ls_fieldcat-tabname       = 'IT_OUTPUT'.
*    APPEND ls_fieldcat TO pt_fieldcat.
*    CLEAR ls_fieldcat.
*    pos = pos + 1.
*  ENDIF.
*
*  ls_fieldcat-col_pos       = pos.
*  ls_fieldcat-fieldname     = 'MESSAGE'.
*  ls_fieldcat-seltext_l     = 'Status Message'.
*  ls_fieldcat-tabname       = 'IT_OUTPUT'.
*  APPEND ls_fieldcat TO pt_fieldcat.
*  CLEAR ls_fieldcat.
*  pos = pos + 1.
*
*ENDFORM.                    " field_fill

Regards

Gopi