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

Selection Screen Disappearing on error

yogesh_pathak
Participant
0 Likes
2,684

Hi

I am new to ABAP.

Below is the driver program for Smartform,

after:

Step-1 Entering data at selection screen

Step-2 Pressing Execution Button

An error is displaying 'Document no. not found' but the problem is, as soon as the error appears, selection screen goes blank, its not staying.

Please suggest correction.

With warm regards.

Yogesh.


*&---------------------------------------------------------------------*
*& Report  Z_MM_GPASS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_MM_GPASS.

tables: MSEG,ADRC,T001W,MAKT .
data: FM_NAME TYPE RS38L_FNAM.

*& Selection Screen
Selection-screen: begin of block b1 with frame title t1.
Parameter:   Docno   like      MSEG-MBLNR ,
             YEAR    like      MSEG-MJAHR .
selection-screen: end of block b1.

*& Comment on selection screen
At selection-screen output .
t1 = 'Selection-Screen' .

*& Data validation at selection screen
At selection-screen .
select single * from MSEG where MBLNR = docno and MJAHR = YEAR .

if sy-subrc <> 0.
message 'Document no. not found' type 'E'.
endif.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME                 = 'Z_MM_PASS'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 IMPORTING
   FM_NAME                  = FM_NAME
 EXCEPTIONS
   NO_FORM                  = 1
   NO_FUNCTION_MODULE       = 2
   OTHERS                   = 3
          .
IF SY-SUBRC <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION FM_NAME
  EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
    DOCNO                      = DOCNO
    YEAR                       = YEAR
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          .
IF SY-SUBRC <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Code Formattted by: Alvaro Tejada Galindo on Jan 7, 2009 2:30 PM

Hi

I am new to ABAP.

Below is the driver program for Smartform,

after:

Step-1 Entering data at selection screen

Step-2 Pressing Execution Button

An error is displaying 'Document no. not found' but the problem is, as soon as the error appears, selection screen goes blank, its not staying.

Please suggest correction.

With warm regards.

Yogesh.


*&---------------------------------------------------------------------*
*& Report  Z_MM_GPASS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_MM_GPASS.

tables: MSEG,ADRC,T001W,MAKT .
data: FM_NAME TYPE RS38L_FNAM.

*& Selection Screen
Selection-screen: begin of block b1 with frame title t1.
Parameter:   Docno   like      MSEG-MBLNR ,
             YEAR    like      MSEG-MJAHR .
selection-screen: end of block b1.

*& Comment on selection screen
At selection-screen output .
t1 = 'Selection-Screen' .

*& Data validation at selection screen
At selection-screen .
select single * from MSEG where MBLNR = docno and MJAHR = YEAR .

if sy-subrc <> 0.
message 'Document no. not found' type 'E'.
endif.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME                 = 'Z_MM_PASS'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 IMPORTING
   FM_NAME                  = FM_NAME
 EXCEPTIONS
   NO_FORM                  = 1
   NO_FUNCTION_MODULE       = 2
   OTHERS                   = 3
          .
IF SY-SUBRC <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION FM_NAME
  EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
    DOCNO                      = DOCNO
    YEAR                       = YEAR
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          .
IF SY-SUBRC <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Code Formattted by: Alvaro Tejada Galindo on Jan 7, 2009 2:30 PM

17 REPLIES 17
Read only

Former Member
0 Likes
2,216

Please keep a break point and check if the correct document number is passed. Looks like exception is triggered stating : 'Document Number not found'.

Read only

0 Likes
2,216

Hi,

Thanks 4 ur answer.

On passing valid Document Number and Year output of the smartform is coming properly, but this is not done.

FYKK

Read only

Sm1tje
Active Contributor
0 Likes
2,216

You are not catching the error returning from one of your function modules correctly?


IF SY-SUBRC 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

This is why you screen is returning blank.Check the return code yourself and do something like this, depending on your requirement of course:


IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
                INTO mtext 
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
write:/1 mtext.
      ENDIF.

Edited by: Micky Oestreich on Jan 7, 2009 8:51 AM

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 2:31 PM

Read only

0 Likes
2,216

I have replaced (1) with (2)

(1)


if sy-subrc <> 0.
message 'Document no. not found' type 'E'.
endif.

(2)


IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
INTO mtext
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
write:/1 mtext.
ENDIF.

Program syntactically correct.

but still I'm facing the same problem, for your kind knowledge I don't know what is return code

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 2:32 PM

Read only

0 Likes
2,216

*I have replaced


if sy-subrc <> 0.
message 'Document no. not found' type 'E'.
endif.

  • with


IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
INTO mtext
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
write:/1 mtext.
ENDIF.

*Program sintactically correct.

*but still I'm facing the same problem, for your kind knowledge I don't know what is return code

Edited by: Yogesh Pathak on Jan 7, 2009 9:45 AM

Messege posted more than one time due to "SERVER ERROR" while posting., sorry for inconvenience.

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 2:34 PM

Read only

Sm1tje
Active Contributor
0 Likes
2,216

For your understanding, the return code = SY-SUBRC.

If SY-SUBRC <> 0 (in case of function modules), this normally means something went 'wrong', in this case the document was not found.

Read only

dev_parbutteea
Active Contributor
0 Likes
2,216

Hi,

whenever you get an error message just display your error like this:


MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 DISPLAY LIKE 'E'.
STOP.

Regards,

Dev.

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 2:33 PM

Read only

0 Likes
2,216

Sorry Sir,

same result

Read only

0 Likes
2,216

Hi,

after your validation please put the START-OF-SELECTION block before calling the smartform,


*& Data validation at selection screen
AT SELECTION-SCREEN .
  SELECT SINGLE * FROM mseg WHERE mblnr = docno AND mjahr = year .

  IF sy-subrc <> 0.
    MESSAGE 'Document no. not found' TYPE 'E'.
  ENDIF.


START-OF-SELECTION.

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 2:35 PM

Read only

Former Member
0 Likes
2,216

Hi,

The program terminates when type E error ocurs..hence in your case try to use Type 'I'..information

Regards

Vasavi Kotha

Read only

0 Likes
2,216

Hi,

Thanks for your reply

I have tried with 'I'

but the result is same

Read only

Sm1tje
Active Contributor
0 Likes
2,216

First I want to apoligize for the fact that my first reply was not correct, since I was looking at the wrong return code. Your problem is not caused by the function modules (return codes from that) but by the first return code after the select.

I recreated your report, but I don't seem to have this problem. Is this all the coding your are using, or has something changed.

Read only

0 Likes
2,216

Sir,

Please dont apoligize and thanks for your reply

after this driver program Smartform remains.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,216

Hello Yogesh,

Welcome to SDN )


*& Data validation at selection screen
At selection-screen .
select single * from MSEG where MBLNR = docno and MJAHR = YEAR .

if sy-subrc 0.
message 'Document no. not found' type 'E'.
endif.

Change this to:


*& Data validation at selection screen
At selection-screen .
select single * from MSEG where MBLNR = docno and MJAHR = YEAR .

if sy-subrc 0.
* message 'Document no. not found' type 'E'.
message 'Document no. not found' type 'I'.
LEAVE LIST-PROCESSING.
endif.

This will solve the problem. You will get an information msg & will be directed back to the selectn-screen.

BR,

SUhas

Read only

0 Likes
2,216

Hi,

Thanks for your reply

I have done the same,

Information messages came, output of the form came on screen, with document no entered on selection screen, which was wrong document number.

Read only

Former Member
0 Likes
2,216

Hi yogesh,

when never you are using events like at selection-screen output, at selection-screen you must be carefull.

I think you are not used the event 'START-OF-SELECTION' at the begining of the FM 'SSF_FUNCTION_MODULE_NAME'. use that event your problem will be solved.

Read only

yogesh_pathak
Participant
0 Likes
2,216

Instead of executing program from Transaction SE38 (Driver Program) I was executing Smartforms program without making TCODE for the same and that was the reason, after showing error Selection Screen was getting blank. As I was directed from ABAP IBM Team Lead to do on my own and I was ignore in this case. So please pardon me for that, and many many thanks to who so ever reply my post. Once again Sorry for posting such a silly question, and thanks for replies. - Yogesh Pathak