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: 

smartforms.

Former Member
0 Kudos
196

Hi..

i want to get the data from 2 database table in smartform. how to do this.

8 REPLIES 8

Former Member
0 Kudos
128

Either change your print program to extract the data and add these tables to the interface of the smartfrom.

or

Create a program node in your smartform and write some ABAP to read the desired tables.

Regards,

Nick

Former Member
0 Kudos
128

Develop a print program in SE38 and then execute the report.... Here is a sample code to extract data from 2 database tables......

Or create a node in SMARTFORM and then write the same code there to achieve your requirement.........

DATA: BEGIN OF fs_spfli,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

countryfr TYPE spfli-countryfr,

END OF fs_spfli.

DATA: BEGIN OF fs_sflight,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

fldate TYPE sflight-fldate,

price TYPE sflight-price,

END OF fs_sflight.

DATA: BEGIN OF fs_outtab,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

countryfr TYPE spfli-countryfr,

fldate TYPE sflight-fldate,

price TYPE sflight-price,

END OF fs_outtab.

DATA: t_spfli LIKE STANDARD TABLE OF fs_spfli,

t_sflight LIKE STANDARD TABLE OF fs_sflight,

t_outtab LIKE STANDARD TABLE OF fs_outtab.

START-OF-SELECTION.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE t_spfli.

END-OF-SELECTION.

SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE t_sflight.

LOOP AT t_sflight INTO fs_sflight.

READ TABLE t_spfli INTO fs_spfli with key carrid = fs_sflight-carrid

.

IF sy-subrc EQ 0.

MOVE fs_spfli-carrid TO fs_outtab-carrid.

MOVE fs_spfli-connid TO fs_outtab-connid.

MOVE fs_spfli-countryfr TO fs_outtab-countryfr.

MOVE fs_sflight-fldate TO fs_outtab-fldate.

MOVE fs_sflight-price TO fs_outtab-price.

APPEND fs_outtab TO t_outtab.

ENDIF.

CLEAR fs_spfli.

CLEAR fs_sflight.

ENDLOOP.

Regards,

Pavan

0 Kudos
128

then how to declare the table in smartforms

0 Kudos
128

If you are wanting to pass data from your print program to your form add the table to the interface of the form in Global Settings -> Form interface, tab Tables.

The structure of your table will need to be declared in the data dictionary (SE11) in order to be able to use it in both your print program and Smartform.

Regards,

Nick

Former Member
0 Kudos
128

check this code:

REPORT YZDS_SMARTFORM_1 .

Tables: bkpf, bseg.

*----


*Internal Tables to be used.

*----


data: begin of int_table1 occurs 0.

include structure bkpf.

data: end of int_table1.

data: begin of int_table2 occurs 0.

include structure bseg.

data: end of int_table2.

*----


*Selection Options to be used.

*----


select-op! tions s_belnr for bkpf-belnr memory id 001.

select-options s_bukrs for bkpf-bukrs memory id 002.

select * from bkpf where belnr in s_belnr

and bukrs in s_bukrs.

move-corresponding bkpf to int_table1.

append int_table1.

endselect.

*----


*Calling the funtion module which was generated by the Smartform.

*----


Call function 'SSF_FUNCTION_MODULE_NAME'

Exporting

formname = 'yzds_zsmart'

Importing

fm_name = '/1BCDWB/SF00000002'

Exceptions

no_form = 1

no_function_module = 2

others = 3.

if sy-sbrc <> 0.

write :? 'ERROR ERROR'.

endif.

Call funtcion fm_name

tables

l_bkpf = int_table1

Exceptions

formatting_error = 1

internal_error = 2

send_error = 3

user_cancelled = 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.

-


reward if useful

anju

Former Member
0 Kudos
128

Hi,

Extract the data using join in driver program.

Move that data to internal table & equate that internal table to the structure you are using in smartform.

e.g.

LOOP AT int_final.

MOVE-CORRESPONDING int_final TO int_final1.

APPEND int_final1.

CALL FUNCTION fm_name

EXPORTING

control_parameters = control

TABLES

zven_whtax_cert = int_final1.

CLEAR int_final1.

REFRESH: int_final1.

ENDAT.

ENDLOOP.

Hope this helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos
128

Hi ,

For that u have to create structure which contain fields of two table and then pas this table as table in input.

Rewards if it will helpful.

former_member196280
Active Contributor
0 Kudos
128

Create program lines in smartforms and retrive data from two tables into one internal table.

Sample for crating table in smartform

sMART fORM

uSING TABLE IN Smart Form

1) Tcode --> SmartForms

2) Form name --> Z_SF_TEST Create

3) Under Global settings

a) Form Interface

Table Tab

ITAB LIKE EKPO

b) GLOBAL Definitions

WA_NETPR LIKE EKPO-NETPR

In smart forms if we want to display quantity and currency fields. We can't directly display currency field and quantity fields

For that we have to create an extra variable in global definitions

Ex: netpr FIELD of EKPO

CREATE program lines and specify WA_NETWR = itab-netpr.

4) RT CLick on main Window

CREATE --> TABLE

Click Table painter

DEFAULT %LTYPE will be Created

a) If you want more like Header footer etc add by rt click on %LTYPE1

Table (Tab)

%LTYPE Radio(SELECT) 5 CM 5 CM 6 CM

CLICK on DATA (Tab)

INTERNAL TABLE ITAB LIKE ITAB

5)RT click on table control and create --> program lines

General attribute (Tab)

INPUT PARAMETER OUTPUT PARAMETER

itab WA_NETPR

Code Area

WA_NETWR = ITAB-NETPR.

6) RT CLcick on table ctl and create 3 text to display the fields

a) % text1 +button(insert field)

FIELD name &itab-ebeln&

Output options (tab)

Check New line LINETYPE %Ltype1

check new cell

b) % text2

& itab-ebelp&

output options

check new cell

c) % text2

& wa_netpr&

output options

check new cell

Report ac

Tables ekpo.

Data: itab1 like ekpo occurs 0 with header line.

select * into table itab1 from ekpo.

Call function module

Regards,

Sairam