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: 

SALV to Smartforms programm call

hossain_rajib55
Explorer
0 Kudos

Hello everyone,I need a help.I am trying to create a smartforms which is already created in SALV reports.Now,I want to create a smartforms where previous SALV report will be called,it means want to convert salv report to smartforms.

6 REPLIES 6

Florian
Active Contributor
0 Kudos

Take the itab from the salv..

pass it to the smartforms..

create table inside the form which look whatever you want to have it like..

Done.

That's it... and yes, you have to do it that way. No "Auto"-Convert is there, if it should be a smartform.

raymond_giuseppi
Active Contributor
0 Kudos

Well 'I am trying to create a smartforms which is already created' so you are done already?

What's the exact problem

  • creation of a smartforms (which already exist)
  • calling a smartforms
  • handling the print request in ALV
  • something else we have to guess

0 Kudos

Handle the print request in ALV.

0 Kudos

Hello Raymond !

I create a smartforms name 'xyz'. now i want to call the smartform when print button is pressed.

REPORT Y_TEST_SMARTFORMS_9515.
Tables: makt.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_matnr FOR makt-matnr.
SELECTION-SCREEN END OF BLOCK b1.


types: BEGIN OF itab,
matnr TYPE makt-matnr,
MAKTX TYPE makt-MAKTX,
END OF itab.

data: dDesc TYPE makt-maktx.
data: itab TYPE TABLE OF itab,
itab1 TYPE itab,
fm_name TYPE rs38l_fnam,
wa TYPE itab.
data: in type p.



select makt~matnr makt~maktx
INTO CORRESPONDING FIELDS OF TABLE itab FROM mara
inner join makt on mara~matnr = makt~matnr
WHERE mara~matnr in s_matnr.
sort itab by matnr.
delete ADJACENT DUPLICATES FROM itab.

LOOP AT itab INTO wa.
IF sy-subrc <> 0.
SELECT SINGLE maktx INTO dDesc FROM makt where matnr = wa-matnr.
wa-maktx = dDesc.
clear dDesc.
ENDIF.
ENDLOOP.


DATA: gr_table TYPE REF TO cl_salv_table,
gr_funct TYPE REF TO cl_salv_functions,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
gr_sorts TYPE REF TO cl_salv_sorts,
gr_sort TYPE REF TO cl_salv_sort,
gr_aggrs TYPE REF TO cl_salv_aggregations,
layout_settings TYPE REF TO cl_salv_layout,
layout_key TYPE salv_s_layout_key,
gr_grid TYPE REF TO cl_salv_form_layout_grid,
gr_header TYPE REF TO cl_salv_form_element,
lv_date_from TYPE char20,
lv_date_to TYPE char20,
lv_count TYPE sy-index,
lv_text TYPE string,
lv_text1 TYPE string.

DATA: lt_binding TYPE salv_t_hierseq_binding.
DATA: ls_binding TYPE salv_s_hierseq_binding.


TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = itab.
CATCH cx_salv_msg.
ENDTRY.


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMM_GENERIC_NAME'
* 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
Mat_Desc = dDesc
TABLES
itab = itab
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.




*****Add Report Header

gr_table->set_top_of_list( gr_header ).

layout_settings = gr_table->get_layout( ).
layout_key-report = sy-repid.
gr_funct = gr_table->get_functions( ).
gr_funct->set_all( abap_true ).

layout_settings->set_default( abap_true ).

layout_settings->set_key( layout_key ).
layout_settings->set_save_restriction( if_salv_c_layout=>restrict_none ).

gr_columns = gr_table->get_columns( ).
gr_columns->set_optimize( ).

gr_column ?= gr_columns->get_column( 'MATNR' ).
gr_column->set_short_text( 'Matnr' ).
gr_column->set_medium_text( 'Material Numb.' ).
gr_column->set_long_text( 'Material Number' ).
**

gr_column ?= gr_columns->get_column( 'MAKTX' ).
gr_column->set_short_text( 'Mat.Desc' ).
gr_column->set_medium_text( 'Mat.Desc' ).
gr_column->set_long_text( 'Material Description' ).
gr_table->display( ).

0 Kudos

You could handle events BEFORE/AFTER_SALV_FUNCTION of CL_SALV_EVENTS (GET_EVENT) to call your SmartForms during standard print function or add your own function and handle event ADDED_FUNCTION.

0 Kudos

Hi,

There are some demo programs in SE38 start with SALV*

e.g.

SALV_DEMO_TABLE_FUNCTIONS

Hope it help,

Nam