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

Problems with screens and smartforms

Former Member
0 Likes
1,329

Hello! I created 2 screens, on the first screen I Have 1 field, where I need to type client number and execute button(which sends me to the second screen), on the second screen There must be information about that client number, which i typed on the first screen. The information must be without table. Ho to do that? I made first screen, but I don`t know how to make the second one.

Also on the second screen there must be a button, which sends to the Smartform preview for client number, which was typed on the first screen. How to make that? Please help me, I`m a newbie.. 

Hello! I created 2 screens, on the first screen I Have 1 field, where I need to type client number and execute button(which sends me to the second screen), on the second screen There must be information about that client number, which i typed on the first screen. The information must be without table. Ho to do that? I made first screen, but I don`t know how to make the second one.

Also on the second screen there must be a button, which sends to the Smartform preview for client number, which was typed on the first screen. How to make that? Please help me, I`m a newbie.. 

3 REPLIES 3
Read only

arindam_m
Active Contributor
0 Likes
943

Hi,

Check SET/GET parameters codes and examples for passing values between screens. Also in the 2nd screen you can display with out table as a ALV list may be.

Cheers,

Arindam

Read only

FredericGirod
Active Contributor
0 Likes
943

Hi Albert,

have a look to this sample code, maybe you will find all your informations

you have to create a screen 100 with a custome OBJ_CUSTOM, a status with the button BACK CANC EXIT activate and replace all the XXXX /  YYYYY

don't forget the points

Fred

REPORT zprogramme_name
       NO STANDARD PAGE HEADING.

*------------------------------ TABLES -------------------------------*

TABLES : xxxx .

*------------------------------- DATA --------------------------------*

DATA : gw_ok_code TYPE syucomm ,
       gw_actvt       TYPE activ_auth ,

       obj_grid       TYPE REF TO cl_gui_alv_grid ,
       obj_container  TYPE REF TO cl_gui_custom_container ,

       itg_data       LIKE TABLE OF xxxx WITH HEADER LINE ,
       itg_fcat       TYPE lvc_t_fcat .

*------------------------- SELECTION SCREEN --------------------------*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
PARAMETERS : p_xxxxx TYPE xxxxx
                     OBLIGATORY.
SELECT-OPTIONS : s_xxxxx FOR xxxx-xxxxx ,
                 s_xxxxx FOR xxxx-xxxxx .
SELECTION-SCREEN END OF BLOCK b1 .

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
PARAMETERS : p_form TYPE tdsfname
                    OBLIGATORY
                    DEFAULT 'ZMY_BEAUTFULE_SMARTFORMS'.
SELECTION-SCREEN END OF BLOCK b2.

*------------------------------ EVENTS -------------------------------*

INITIALIZATION.
 

AT SELECTION-SCREEN.
  MOVE 3 TO gw_actvt.
  AUTHORITY-CHECK OBJECT 'ZZZZZZZ'
           ID 'XXXXX' FIELD p_xxxxx
           ID 'ACTVT' FIELD gw_actvt.
  IF sy-subrc NE space.
    MESSAGE i398(00) WITH text-e01.
    LEAVE TO SCREEN 0.
  ENDIF.

*------------------------------- MAIN --------------------------------*

START-OF-SELECTION.

* Call screen 100.

  CALL SCREEN 100.


END-OF-SELECTION.

*----------------------------------------------------------------------*
*   Module PBO Screen 100.                                             *
*----------------------------------------------------------------------*

MODULE pbo_100 OUTPUT.


  DATA : is_variant TYPE disvariant ,
         is_layout  TYPE lvc_s_layo ,
         is_log     TYPE bal_s_log .

* Check Grid object not already exist.

  CHECK obj_grid IS INITIAL.

* Set menu-painter.

  SET PF-STATUS '100'.

* Set title-bar.

  SET TITLEBAR '100'.

* Get data.

  PERFORM p_get_data.

* Create the fieldcatalog.

  PERFORM p_build_fcat.

* Create the container.

  CREATE OBJECT obj_container
         EXPORTING container_name = 'OBJ_CUSTOM'.

* Create the grid object.

  CREATE OBJECT obj_grid
         EXPORTING i_parent = obj_container.

* Set the display variant.

  MOVE : sy-repid TO is_variant-report ,
         sy-uname TO is_variant-username ,
         '1'      TO is_variant-handle.

* Update the layout.

  MOVE 'A' TO is_layout-sel_mode.

* Load data into the grid.

  CALL METHOD obj_grid->set_table_for_first_display
    EXPORTING
      is_layout       = is_layout
      is_variant      = is_variant
      i_save          = 'A'
    CHANGING
      it_outtab       = itg_data[]
      it_fieldcatalog = itg_fcat.


ENDMODULE. " PBO_100

*----------------------------------------------------------------------*
*   Module PAI Screen 100                                              *
*----------------------------------------------------------------------*

MODULE pai_100 INPUT.

* Dispatch the return code.

  CASE gw_ok_code.

*   Escape

    WHEN 'EXIT' OR
         'CANC' OR
         'BACK'.
      CALL METHOD obj_grid->free.
      FREE obj_grid.
      LEAVE TO SCREEN 0.

*   Print the form.

    WHEN 'PR_FORM'.
      PERFORM p_print_form.

    WHEN OTHERS.
      CALL METHOD cl_gui_cfw=>dispatch.
  ENDCASE.

* Clear code.

  CLEAR gw_ok_code.


ENDMODULE. " PAI_100

*----------------------------------------------------------------------*
*   Form P_BUILD_FCAT.                                                 *
*----------------------------------------------------------------------*
*   Create the field catalog of the ALV Grid.                          *
*----------------------------------------------------------------------*

FORM p_build_fcat.

* Build field catalog.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name   = 'XXXX'
      i_bypassing_buffer = 'X'
    CHANGING
      ct_fieldcat        = itg_fcat
    EXCEPTIONS
      OTHERS             = 3.

ENDFORM. " P_BUILD_FCAT.

*----------------------------------------------------------------------*
*   Form P_GET_DATA.                                                   *
*----------------------------------------------------------------------*
*   Retrieve all the data necessary to the report.                     *
*----------------------------------------------------------------------*

FORM p_get_data.

* Clear the data into the table ITG_DATA.

  REFRESH itg_data.

* Get all the lines of XXXX corresponding to the selection.

  SELECT *
         INTO TABLE itg_data
         FROM xxxx
         WHERE xxxxx EQ p_xxxxx
         AND   xxxxx IN s_xxxxx
         AND   xxxxx IN s_xxxxx.
  IF sy-subrc NE space.
    MESSAGE i398(00) WITH text-e01.
  ENDIF.

ENDFORM. " P_GET_DATA

*----------------------------------------------------------------------*
*   Form P_PRINT_FORM.                                                 *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

FORM p_print_form.


  DATA : is_row            TYPE lvc_s_row ,
         it_row            TYPE lvc_t_row  ,
         it_bkpf           LIKE TABLE OF bkpf WITH HEADER LINE ,
         w_count           TYPE i ,
         w_funcname        TYPE tdsfname ,
         w_reclam_viaf     TYPE char1 ,

         is_control_param  TYPE ssfctrlop ,
         is_composer_param TYPE ssfcompop ,
         is_job_info       TYPE ssfcrescl .

* Get selected rows

  CALL METHOD obj_grid->get_selected_rows
    IMPORTING
      et_index_rows = it_row.

* Copy selected rows to a temporary table.

  LOOP AT it_row
       INTO is_row.
    READ TABLE itg_data
         INDEX is_row-index.
    IF sy-subrc EQ space.
      APPEND itg_data TO it_bkpf.
    ENDIF.
  ENDLOOP.

  DESCRIBE TABLE it_bkpf LINES w_count.
  IF w_count EQ 0.
    MESSAGE i398(00) WITH text-e02.
    LEAVE TO SCREEN 0.
  ENDIF.

* Get the function name of the form

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = p_form
    IMPORTING
      fm_name  = w_funcname
    EXCEPTIONS
      OTHERS   = 3.

* Prepare the printer parameters.

  MOVE : 'PRINTER'                 TO is_control_param-device ,
         ' '                       TO is_control_param-no_dialog ,
         sy-langu                  TO is_control_param-langu ,
         'X'                       TO is_composer_param-tdnewid ,
         'X'                       TO is_composer_param-tdfinal .

* Call the function of the Smartforms

  CALL FUNCTION w_funcname
    EXPORTING
      control_parameters = is_control_param
      output_options     = is_composer_param
      user_settings      = ' '
    IMPORTING
      job_output_info    = is_job_info
    TABLES
      itg_xxxx           = it_xxxx
    EXCEPTIONS
      gsber_different    = 5
      OTHERS             = 6.

  IF sy-subrc NE space.
    IF sy-subrc EQ 5.
      MESSAGE i398(00) WITH text-e03.
    ELSE.
      MESSAGE ID sy-msgid
              TYPE sy-msgty
              NUMBER sy-msgno.
    ENDIF.
  ENDIF.

ENDFORM. " P_PRINT_FORM.

Read only

Former Member
0 Likes
943

Ok, so you have your first screen.

If its a normal selection screen, then add this statement in the start-of-selection.

If its a screen, in the PAI module, add this statement.

 

        call screen 200.

Double click on 200 and create the screen layout and PBO , PAI just as  you did for the first screen.

For directly going to print preview of smarforms,

data: control TYPE ssfctrlop,

control_parameters TYPE ssfctrlop.

Set the OUTPUT OPTIONS paramter TDDEST to your printer name.

Set the CONTROL PARAMETERS and control parameters as shown below,

control-preview = 'X'.

control-no_open = 'X'.

control-no_close = 'X'.

control-no_dialog = 'X'.

control-device = 'PRINTER'.

control_parameters-no_dialog = 'X'.

control_parameters-no_open = 'X'.

control_parameters-no_close = 'X'.

OUTPUT_OPTIONS-TDDEST = 'PRINTER NAME'.

OUTPUT_OPTIONS-TDNOPRINT = 'X'.

CALL FUNCTION 'SSF_MODULE_NAME'         "Name of function module of smartform.

EXPORTING

output_options     = output_options

control_parameters = control

user_settings      = ' '

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.