Application Development 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: 

How do you gracefully error/exit an ALV Grid Controls

Former Member
0 Kudos

I have a report that uses ALV grid controls. Inside the screens, I am opening a file, and need to give an error if the file does not successfully open. I do not have any problem doing this, BUT when I error, it takes me totally out of the program, and I really just want to get back to the report selection screen. I have not been successful in finding out how to do this. Any help is very much appreciated!! Thanks!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Here is how some of the code looks....this is the initial call into the first screen of the ALV grid. From the screen 100 of the ALV Grid, I want to be able to hit the green back arrow button and go back to the report selection criteria so that the user can easily change a file name in case they entered it wrong, etc. Here is the code:

START-OF-SELECTION.

IF NOT p_ofile IS INITIAL.

CONCATENATE p_opath p_ofile INTO p_ofile.

ENDIF.

IF NOT p_sfile IS INITIAL.

CONCATENATE p_spath p_sfile INTO p_sfile.

ENDIF.

IF NOT p_ifile IS INITIAL.

CONCATENATE p_ipath p_ifile INTO p_ifile.

ENDIF.

IF NOT p_ofile2 IS INITIAL.

CONCATENATE p_opath p_ofile2 INTO p_ofile2.

ENDIF.

IF NOT p_sfile2 IS INITIAL.

CONCATENATE p_spath p_sfile2 INTO p_sfile2.

ENDIF.

IF NOT p_ifile2 IS INITIAL.

CONCATENATE p_ipath p_ifile2 INTO p_ifile2.

ENDIF.

IF NOT p_ofile3 IS INITIAL.

CONCATENATE p_opath p_ofile3 INTO p_ofile3.

ENDIF.

IF NOT p_sfile3 IS INITIAL.

CONCATENATE p_spath p_sfile3 INTO p_sfile3.

ENDIF.

IF NOT p_ofile4 IS INITIAL.

CONCATENATE p_opath p_ofile4 INTO p_ofile4.

ENDIF.

IF NOT p_sfile4 IS INITIAL.

CONCATENATE p_spath p_sfile4 INTO p_sfile4.

ENDIF.

IF NOT p_ofile5 IS INITIAL.

CONCATENATE p_opath p_ofile5 INTO p_ofile5.

ENDIF.

IF NOT p_ofile6 IS INITIAL.

CONCATENATE p_opath p_ofile6 INTO p_ofile6.

ENDIF.

IF NOT p_ofile7 IS INITIAL.

CONCATENATE p_opath p_ofile7 INTO p_ofile7.

ENDIF.

IF NOT p_ofile8 IS INITIAL.

CONCATENATE p_opath p_ofile8 INTO p_ofile8.

ENDIF.

SELECT * FROM zgedwsostmg INTO TABLE xzgedwsostmg.

SELECT SINGLE delimiter_hex FROM zgedwflcnfg

INTO g_delimiter_hex

WHERE kappl = 'V1'.

g_hex_value = g_delimiter_hex.

END-OF-SELECTION.

PERFORM load_header_table.

SET SCREEN 100.

Screen 100 Code

PROCESS BEFORE OUTPUT.

MODULE status_0100.

MODULE create_objects.

PROCESS AFTER INPUT.

MODULE pai_100 at exit-command.

MODULE pai_100 INPUT.

CASE ok_code.

WHEN 'BACK'.

g_back = 'X'.

PERFORM exit_program.

  • exit.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN 'CANC'.

PERFORM exit_program.

ENDCASE.

CLEAR ok_code.

ENDMODULE. " PAI INPUT

FORM exit_program.

CALL METHOD g_custom_container1->free.

IF NOT g_custom_container2 IS INITIAL.

CALL METHOD g_custom_container2->free.

ENDIF.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc NE 0.

  • add your handling, for example

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = g_repid

txt2 = sy-subrc

txt1 = 'Error in Flush'(500).

ENDIF.

  • LEAVE PROGRAM.

  • set screen 0.

  • leave screen.

leave screen.

  • leave to screen 1000.

  • CALL SELECTION-SCREEN 1000.

  • leave to list-processing.

  • exit.

  • leave to screen 0.

ENDFORM. " exit_program

As you can see by all the commented lines, I have tried several ways to make this work, but without success. Thanks again for any help!!

9 REPLIES 9

Former Member
0 Kudos

Hi krishna,

give information msg instead of error message,

regards,

keerthi.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Interesting, can you post the code for the program.

Regards,

Rich Heilman

Former Member
0 Kudos

hi kristina,

try doing this...

if sy-subrc ne 0.

message e001.

leave to screen 1000.

endif.

hope this helps,

priya.

Former Member
0 Kudos

Thanks so much for all the quick replies! I had already changed the code to just give an information message instead of a hard error, BUT I still need to exit the code gracefully when I hit a back arrow and I need it to go back to the selection screen. I had already tried the 'leave to screen 1000', and that did not work. It actually gave me the following hard error "Selection screen ZGICA_EDW_FILE_REPORT_UTIL 10 was not called using CALL SELECTION-SCREEN". So, I changed the code to do a CALL SELECTION-SCREEN 1000, and that will take me back to the selection screen from the current screen, but it is in loop because it never actually leaves the screen that called it. It calls the selection screen, but when I hit execute again, it goes right back to the place where the call to the selection screen was made and gets back into the PBO of that screen. So, I can't figure out how to exit the dialog screen to go back to the actual report program that is calling the ALV grid controls.

Former Member
0 Kudos

Here is how some of the code looks....this is the initial call into the first screen of the ALV grid. From the screen 100 of the ALV Grid, I want to be able to hit the green back arrow button and go back to the report selection criteria so that the user can easily change a file name in case they entered it wrong, etc. Here is the code:

START-OF-SELECTION.

IF NOT p_ofile IS INITIAL.

CONCATENATE p_opath p_ofile INTO p_ofile.

ENDIF.

IF NOT p_sfile IS INITIAL.

CONCATENATE p_spath p_sfile INTO p_sfile.

ENDIF.

IF NOT p_ifile IS INITIAL.

CONCATENATE p_ipath p_ifile INTO p_ifile.

ENDIF.

IF NOT p_ofile2 IS INITIAL.

CONCATENATE p_opath p_ofile2 INTO p_ofile2.

ENDIF.

IF NOT p_sfile2 IS INITIAL.

CONCATENATE p_spath p_sfile2 INTO p_sfile2.

ENDIF.

IF NOT p_ifile2 IS INITIAL.

CONCATENATE p_ipath p_ifile2 INTO p_ifile2.

ENDIF.

IF NOT p_ofile3 IS INITIAL.

CONCATENATE p_opath p_ofile3 INTO p_ofile3.

ENDIF.

IF NOT p_sfile3 IS INITIAL.

CONCATENATE p_spath p_sfile3 INTO p_sfile3.

ENDIF.

IF NOT p_ofile4 IS INITIAL.

CONCATENATE p_opath p_ofile4 INTO p_ofile4.

ENDIF.

IF NOT p_sfile4 IS INITIAL.

CONCATENATE p_spath p_sfile4 INTO p_sfile4.

ENDIF.

IF NOT p_ofile5 IS INITIAL.

CONCATENATE p_opath p_ofile5 INTO p_ofile5.

ENDIF.

IF NOT p_ofile6 IS INITIAL.

CONCATENATE p_opath p_ofile6 INTO p_ofile6.

ENDIF.

IF NOT p_ofile7 IS INITIAL.

CONCATENATE p_opath p_ofile7 INTO p_ofile7.

ENDIF.

IF NOT p_ofile8 IS INITIAL.

CONCATENATE p_opath p_ofile8 INTO p_ofile8.

ENDIF.

SELECT * FROM zgedwsostmg INTO TABLE xzgedwsostmg.

SELECT SINGLE delimiter_hex FROM zgedwflcnfg

INTO g_delimiter_hex

WHERE kappl = 'V1'.

g_hex_value = g_delimiter_hex.

END-OF-SELECTION.

PERFORM load_header_table.

SET SCREEN 100.

Screen 100 Code

PROCESS BEFORE OUTPUT.

MODULE status_0100.

MODULE create_objects.

PROCESS AFTER INPUT.

MODULE pai_100 at exit-command.

MODULE pai_100 INPUT.

CASE ok_code.

WHEN 'BACK'.

g_back = 'X'.

PERFORM exit_program.

  • exit.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN 'CANC'.

PERFORM exit_program.

ENDCASE.

CLEAR ok_code.

ENDMODULE. " PAI INPUT

FORM exit_program.

CALL METHOD g_custom_container1->free.

IF NOT g_custom_container2 IS INITIAL.

CALL METHOD g_custom_container2->free.

ENDIF.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc NE 0.

  • add your handling, for example

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = g_repid

txt2 = sy-subrc

txt1 = 'Error in Flush'(500).

ENDIF.

  • LEAVE PROGRAM.

  • set screen 0.

  • leave screen.

leave screen.

  • leave to screen 1000.

  • CALL SELECTION-SCREEN 1000.

  • leave to list-processing.

  • exit.

  • leave to screen 0.

ENDFORM. " exit_program

As you can see by all the commented lines, I have tried several ways to make this work, but without success. Thanks again for any help!!

0 Kudos

Instead of SET SCREEN 100, use CALL SCREEN 100. In the Exit program form, use SET SCREEN 0 and LEAVE SCREEN.

Set SCREEN 0.
LEAVE SCREEN.

Regards,

Rich Heilman

0 Kudos

Have you tried 'leave screen' followed by 'CALL SELECTION-SCREEN 100'?

0 Kudos

hi kristina,

try using FM POPUP_DISPLAY_MESSAGE.

and then give CALL SELECTION-SCREEN 1000.

i m not sure just try...

Former Member
0 Kudos

Thanks everyone for your fast response!! Rich Hielman's answer seems to work.....Thanks so much Rich!! I made the following change, and it worked. So it seems the CALL SCREEN 100 instead of SET SCREEN 100 was the trick

Instead of SET SCREEN 100, use CALL SCREEN 100. In the Exit program form, use SET SCREEN 0 and LEAVE SCREEN.

Set SCREEN 0.LEAVE SCREEN.

THANKS!!