cancel
Showing results for 
Search instead for 
Did you mean: 

reg Data Passing in Smartforms

former_member186491
Contributor
0 Kudos

Hi All,

I am creating Smartforms using two tables -- BSID and KNKK.

I've defined KUNNR, DATE1 and DATE2 as Input parameters.

Then, I declared I_BSID as of type BSID and I_KNKK as of type KNKK.

In the Initialization I populated I_BSID as per condition.

But, the problem is -- I_BSID does not get populated.

I think, I'm missing some step.

Can anybody give me the idea of fetching data from two tables.

Thanks.

Kumar Saurav.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

first see which field is same and primary key for one table for both table...

i think its kunnr ,by using this you can fetch data using select query......

former_member186491
Contributor
0 Kudos

Hi,

Yes, KUNNR is in both the table.

I'm using the query for that. Still, none of the I_BSID or I_KNKK is getting populated.

I guess, my problem lies somewhere in declaration part.

Can you please guide me the steps to do declaration.

I followed the following steps --

a) Defined KUNNR

DATE1

DATE2

in Form Interface - Import Tab.

b) In Tables

I_BSID

I_KNKK

c) In Global Defnitions - Initializations Tab

SELECT SINGLE * FROM BSID INTO I_BSID
  WHERE KUNNR = KUNNR
  AND BUDAT BETWEEN DATE1 AND DATE2.

Other than this, defined Input Parameter in Initialization Tab

KUNNR

I_BSID

DATE1

DATE2

in Output Parameter of Initialization Tab

I_BSID

These are steps, I've followed. Please suggest me as if I am missing anything?

Thanks.

Kumar Saurav.

Former Member
0 Kudos

Hi,

If you are populating the tables I_BSID and I_KNKK in the initialisation why are you declaring them as import parameters?

Try declaring them as global variables, then populate them in the initialisation, or keep them as import parameters and fill them in the calling program.

Regards,

Nick

former_member186491
Contributor
0 Kudos

Hi,

My poblem still persist.

When I'm using data passing in this manner in Initialization --

date = i_bsid-budat.
          DocNo = i_bsid-vbeln.

It passes those values and displays one line of records - because, I guess it is like fetching one row from a table. But, when I try to loop at I_BSID , it does not reflect any data in I_BSID. There happens to be 0 records.

I guess, I'm doing some mistake in defining ITAB and Work-area.

I defined I_BSID in Tables Tab of Global Declaration.

Can you please suggest how to declare itab and work-area on this table.

Thanks.

Kumar Saurav.

former_member217544
Active Contributor
0 Kudos

Hi Kumar,

Is there Tables tab in global declarations also?Which version you are working on?

Assuming: You are trying to declare it_bsid as table in global data and you are trying to fill this internal table in initialization tab.

Try this way:

In global definitions there are tabs with name 'Types' and 'Global data'

In Types Tab:

DATA: IT_BSID type standard table of BSID,

wa_bsid type bsid.

Now in Global data tab declare these variable:

I_BSID type it_bsid

w_bsid type wa_bsid.

Now you can use them in initializing tab code.

I_BSID as tables variable

and w_bsid as workarea.

Let me know if my assumption is not correct

Regards,

Swarna Munukoti

former_member186491
Contributor
0 Kudos

Hi Swarna,

I'm working on SAP ECC 6.0, and yes, there is TABLES Tab in Form Interface.

I'm defining I_BSID in that Tab of Tables as --

I_BSID   LIKE   BSID

Further, in Import Tab of Form Interface --

KUNNR  TYPE  KNA1-KUNNR
           DATE1  LIKE  BSID-BUDAT

Then, in Global definition, in Types Tab --

types: IT_BSID type standard table of BSID,
wa_bsid type bsid.

And, in Initialization Tab --

date2 = sy-datum.

select single * from bsid into i_bsid
  where kunnr = kunnr
  and budat between date1 and date2.

Now, here is the difference--

when I use --

v_budat = i_bsid-budat.
v_vbeln = i_bsid-vbeln.
v_belnr = i_bsid-belnr.
v_zuonr = i_bsid-zuonr.

This displays one record. But, I need as many as are present.

Then, in Main Window, I used Table and within that table, in Main Area, run a loop at IT_BSID into WA_BSID.

But, data is not getting passed on. It displays nothing. When I debugged, I found that I_BSID is empty.

So, where am I doing some silly mistake...

Please guide.

Thanks.

Kumar Saurav.

former_member186491
Contributor
0 Kudos

One More thing, I have not created the Driver Program for smartforms. I'm just testing it using F8.

But, will it make any difference..?

former_member217544
Active Contributor
0 Kudos

Hi Kumar,

When you need multiple records, you should not restrict your select query with single statement in between,


 
select  * from bsid into table i_bsid
  where kunnr = kunnr
  and budat between date1 and date2.

And as you are populating the table i_bsid in initialization table, remove the declaration from From Interface Tbale tab and keep it is as I explained in my earlier post.

Regards,

Swarna Munukoti

former_member217544
Active Contributor
0 Kudos

Hi Kumar,

No,it doesnt matter until you provide inputsto smartform in the genarated function module.

Regards,

Swarna Munukoti

Former Member
0 Kudos

Hi,

No, it will make no difference how you call it.

And please follow Swarna's (and my earlier) comments about the SELECT SINGLE and the declaration of I_BSID.

Regards,

Nick

former_member186491
Contributor
0 Kudos

Hi Swarna,

I made all necessary changes as per your guidelines.

Now, it says,

You cannot use an internal table as a work area.

and leads to Initialization Tab of Global Definitions.

Thanks.

Kumar saurav.

Edited by: Kumar Saurav on Feb 3, 2010 11:41 AM

former_member217544
Active Contributor
0 Kudos

Hi Kumar,

Can you paste your code in Initialization Tab?

Regards,

Swarna Munukoti

former_member186491
Contributor
0 Kudos

Hi Swarna,

Here it is --

date2 = sy-datum.

select  * from bsid into table i_bsid
  where kunnr = kunnr
  and budat between date1 and date2.

select * from knkk into i_knkk
  where kunnr = kunnr.

In Input Parameter--

KUNNR

I_BSID

I_KNKK

DATE1

In Output Parameter --

W_BSID

W_KNKK

Thanks.

Kumar Saurav.

Former Member
0 Kudos

Well Kumar, I think you could have worked that one out for yourself

If BSID is selecting into a table, then so is KNKK, so the structure of the select statement will need to be the same.

Regards,

Nick

former_member186491
Contributor
0 Kudos

Hi Swarna,

Thanks for your guidelines.

I must thank to Nick also for helping me out.

I got my smartforms running. Thanks a lot.

Kumar Saurav.

former_member217544
Active Contributor
0 Kudos

Hi Kumar,

Nick has already written in his earlier post.


Hi,

Sorry, typo in the code


SELECT * FROM BSID INTO table I_BSID
  WHERE KUNNR = KUNNR
  AND BUDAT BETWEEN DATE1 AND DATE2.
SELECT * FROM KNKK INTO table I_KNKK
  WHERE KUNNR = KUNNR.


You are of course filling a table so you need SELECT * INTO TABLE....

Regards,
Nick

Regards,

Swarna Munukoti

Answers (3)

Answers (3)

Former Member
0 Kudos

if you want to declare those IT as Import parameters fill them in the program that calls the smartform.

if you want to declare those IT as Global Parameters in Smart Forms, do the initialization in Smart Form

Former Member
0 Kudos

Hi,

You define your tables in the TABLES table I_BSID and I_KNKK

With 'Like' and not 'type'.

Define I_BSID_LINE Type BSID in the global definitions.

Check that your values that you are importing from your driver program is populating the kunnr , date1 and date2 values.

Because if it is not getting the kunnr,date1 and date2 values your table will not get populated.

Then in the main window take a table ,

In the table in Data tab write

I BSID INTO IBSID_LINE.

in the tables , main area in the text write the field in capital letters &I_BSID_LINE-KUNNR&

You can write the headetrs in the headers.

I hope you will get the values populated properly.

Regards,

Richa Tripathi

former_member186491
Contributor
0 Kudos

Hi Richa,

Thanks for your reply.

Actually, I_BSID is not being populated. I tried as per your suggestion and declared I_BSID_LINE. But, even then, the data is not getting paased on.

Here, I'd like to mention that if I try to print single row of data; it is happening.

Therefore, I can say that it is problem of handling the itab and loop thereon.

Yes, for your doubts, KUNNR, DATE1 and DATE2 are being read by the smartforms program. Only on that basis one line of data is coming up. But, I have to display all possible data -- not restricted to single record obviously.

Guide me further.

Thanks.

Kumar Saurav.

Former Member
0 Kudos

Hi,

There's a lot of information in this post, and rather than try to pick through what you've tried so far let me explain what I think you need to do.

KUNNR, DATE1 and DATE2 declared on the import tab of the form interface as they are currently.

Declare I_BSID in the Global Data tab of the Global Definitions as TYPE TABLE OF BSID. (and I_KNKK in the same way)

In the initialisation tab specify Input Parameters KUNNR, DATE1, DATE2, I_BSID and I_KNKK, in the Output Parameters I_BSID and I_KNKK.

In the code for the initialisation enter;


SELECT * FROM BSID INTO I_BSID
  WHERE KUNNR = KUNNR
  AND BUDAT BETWEEN DATE1 AND DATE2.
SELECT * FROM KNKK INTO I_KNKK
  WHERE KUNNR = KUNNR.

(Note: In your earlier post you used SELECT SINGLE to read BSID, could explain why you're only getting one record!)

You can now use both I_BSID and I_KNKK in Tables or Loops in your smartform.

Regards,

Nick

former_member186491
Contributor
0 Kudos

Hi Nick,

Thanks for your suggestion.

I tried your way. But, while checking it says

You Cannot use an internal table as a work area

Thanks.

Kumar Saurav.

Former Member
0 Kudos

Hi,

Sorry, typo in the code


SELECT * FROM BSID INTO table I_BSID
  WHERE KUNNR = KUNNR
  AND BUDAT BETWEEN DATE1 AND DATE2.
SELECT * FROM KNKK INTO table I_KNKK
  WHERE KUNNR = KUNNR.

You are of course filling a table so you need SELECT * INTO TABLE....

Regards,

Nick

Former Member
0 Kudos

hi

Delare Form interface--->Import

KUNNR TYPE KUNNR

DATE1 TYPE BUDAT

DATE2 TYPE BUDAT

check i_bsid declaration(It should be in table type)

select BUKRS

KUNNR

from bsid

into table I_BSID

where

kunnr = kunnr

and budat ge DATE1 AND

budat le DATE2.

BREAK-POINT.