Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error message. (urgent)

Hi All,

I am calling a bapi which includes a internal table. In this internal table i have populated the error messages. now i want to display the eroor messages on to the same screen following is my code.

*&----


*& Report ZBAPI_AS1 *

*& *

&----


*& *

*& *

&----


REPORT zbapi_as1 .

TABLES : bse_clr,bkpf.

TYPE-POOLS : slis.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETER : p1 LIKE bse_clr-bukrs_clr,

p2 LIKE bse_clr-gjahr_clr.

SKIP.

PARAMETERS : p_detail RADIOBUTTON GROUP disp DEFAULT 'X',

p_sum RADIOBUTTON GROUP disp.

SELECTION-SCREEN END OF BLOCK b1.

DATA : BEGIN OF zstruct,

bukrs_clr LIKE bse_clr-bukrs_clr,

gjahr_clr LIKE bse_clr-gjahr_clr,

END OF zstruct.

DATA : it_amt TYPE STANDARD TABLE OF zbapi_itab.

DATA : wa_amt TYPE zbapi_itab.

DATA : it_return TYPE STANDARD TABLE OF bapireturn.

DATA : t_return TYPE STANDARD TABLE OF bapireturn.

DATA : wa_return LIKE LINE OF it_return.

*zstruct-bukrs_clr = p1.

*zstruct-gjahr_clr = p2.

DATA : itab TYPE STANDARD TABLE OF zbapi_itab.

DATA : wa TYPE zbapi_itab.

DATA : wa1 TYPE zbapi_itab.

*LOOP AT itab INTO wa.

  • WRITE :/ wa-bukrs,wa-belnr,wa-gjahr,wa-bukrs_clr,wa-belnr_clr,

  • wa-gjahr_clr,wa-usnam.

*ENDLOOP.

DATA : w_flag TYPE flag VALUE 'X'.

DATA : report LIKE sy-repid.

DATA : it_header TYPE slis_t_listheader,

it_events TYPE slis_t_event,

it_catalog TYPE slis_t_fieldcat_alv,

it_catalog1 TYPE slis_t_fieldcat_alv.

DATA : wa_header LIKE LINE OF it_header,

wa_events LIKE LINE OF it_events,

wa_catalog LIKE LINE OF it_catalog,

wa_catalog1 LIKE LINE OF it_catalog1,

wa_layout TYPE slis_layout_alv.

START-OF-SELECTION.

zstruct-bukrs_clr = p1.

zstruct-gjahr_clr = p2.

report = sy-repid.

CLEAR wa_catalog.

wa_catalog-col_pos = '1'.

wa_catalog-fieldname = 'BUKRS_CLR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'Company Code'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '2'.

wa_catalog-fieldname = 'BELNR_CLR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'Acctng Doc.No.'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '3'.

wa_catalog-fieldname = 'GJAHR_CLR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'Fiscal Year'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '4'.

wa_catalog-fieldname = 'BUKRS'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'Company Code 1'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '5'.

wa_catalog-fieldname = 'BELNR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = ''.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '6'.

wa_catalog-fieldname = 'GJAHR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'Fiscal Year 1'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '7'.

wa_catalog-fieldname = 'WRBTR'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'amount'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_catalog.

wa_catalog-col_pos = '8'.

wa_catalog-fieldname = 'USNAM'.

wa_catalog-tabname = 'itab'.

wa_catalog-seltext_m = 'User Name'.

APPEND wa_catalog TO it_catalog.

CLEAR wa_layout.

wa_layout-zebra = 'X'.

wa_events-name = 'TOP-OF-PAGE'.

wa_events-form = 'zbapi_top_of_page'.

APPEND wa_events TO it_events.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '1'.

wa_catalog1-fieldname = 'BUKRS'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'Company Code'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '2'.

wa_catalog1-fieldname = 'BELNR'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'Acctng Doc.No.'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '3'.

wa_catalog1-fieldname = 'GJAHR'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'Fiscal Year'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '4'.

wa_catalog1-fieldname = 'BUKRS_CLR'.

wa_catalog1-tabname = 'IT_AMT'.

wa_catalog1-seltext_m = 'Company Code 1'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '5'.

wa_catalog1-fieldname = 'BELNR_CLR'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = ''.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '6'.

wa_catalog1-fieldname = 'GJAHR_CLR'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'Fiscal Year 1'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '7'.

wa_catalog1-fieldname = 'WRBTR'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'amount'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_catalog1.

wa_catalog1-col_pos = '8'.

wa_catalog1-fieldname = 'USNAM'.

wa_catalog1-tabname = 'it_amt'.

wa_catalog1-seltext_m = 'User Name'.

APPEND wa_catalog1 TO it_catalog1.

CLEAR wa_layout.

wa_layout-zebra = 'X'.

wa_events-name = 'TOP-OF-PAGE'.

wa_events-form = 'zbapi_top_of_page'.

APPEND wa_events TO it_events.

**

IF w_flag = 'X'.

IF p_detail = 'X'.

  • CALL FUNCTION 'Z_AVS_BAPI_AS1'

  • EXPORTING

  • zbapi_struct_as1_import = zstruct

  • IMPORTING

  • return = it_return

  • TABLES

  • zbapi_itab_table = itab.

CALL FUNCTION 'Z_AVS_BAPI_AS1'

EXPORTING

zbapi_struct_as1_import = zstruct

TABLES

zbapi_itab_table = itab

return = it_return.

IF zstruct-bukrs_clr eq space.

LOOP AT it_return INTO wa_return.

WRITE :/ wa_return-message.

  • leave list-processing.

ENDLOOP.

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = report

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = it_catalog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = it_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = itab

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

  • IF sy-subrc <> 0.

  • LEAVE TO SCREEN 110.

  • ENDIF.

*

ENDIF.

ELSEIF p_sum = 'X'.

CALL FUNCTION 'Z_AVS_BAPI_AS1'

EXPORTING

zbapi_struct_as1_import = zstruct

IMPORTING

return = it_return

TABLES

zbapi_itab_table = itab.

  • Loop at itab INTO WA.

  • move-corresponding WA TO WA2.

  • append WA2 TO ITAB2.

*endloop.

*

*loop at itab2 into wa2.

  • WRITE :/ wa2-bukrs,wa2-belnr,wa2-gjahr,wa2-bukrs_clr,wa2-belnr_clr,

  • wa2-gjahr_clr,wa2-usnam.

*endloop.

CLEAR it_amt.

LOOP AT itab INTO wa.

MOVE wa TO wa1.

wa_amt-wrbtr = wa_amt-wrbtr + wa-wrbtr.

AT END OF belnr_clr.

MOVE wa1-bukrs_clr TO wa_amt-bukrs_clr.

MOVE wa1-belnr_clr TO wa_amt-belnr_clr.

MOVE wa1-gjahr_clr TO wa_amt-gjahr_clr.

MOVE wa1-bukrs TO wa_amt-bukrs.

MOVE wa1-belnr TO wa_amt-belnr.

MOVE wa1-gjahr TO wa_amt-gjahr.

MOVE wa1-usnam TO wa_amt-usnam.

APPEND wa_amt TO it_amt.

CLEAR wa_amt.

ENDAT.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = report

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = it_catalog1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = it_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_amt.

  • 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.

*

ENDIF.

ENDIF.

END-OF-SELECTION.

Help me where to include

<b>leave list-processing</b>

Thanx .

Amruta.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question