‎2010 Feb 05 5:32 AM
Good day everyone.
I am developing a smartform. I am having an SAP Script that I want to redo it in smartform. In my smartform I fetch the data from 2 different table. So i have created 2 itabs and sending the data into the final itab. Now in smartforms I have seen some loop statement given where we can enter the itab and work area. Where should I write the code in smart form. I want to display data in table. Should I create a flow logic -> program lines or write the code in initilization. Also i am having a loop inside a loop.
Please help.
Dev.
‎2010 Feb 05 6:03 AM
Thanks everyone for the response.
Actually in form interface -> import I have declared lv_ebeln for which I have to display the purchase order details.
In Initilization I have written the below code.
TABLES: ekko, ekpo.
DATA: lv_ebeln TYPE ekko-ebeln.
DATA: it_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.
SELECT ebeln lifnr ekorg aedat
FROM ekko
INTO TABLE it_ekko
WHERE ebeln = lv_ebeln.
IF sy-subrc = 0. " If values are fetched into it_ekko then fetch the values into it_ekpo
SELECT ebeln menge
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
LOOP AT it_ekko INTO wa_ekko. " move data from wa_ekko to wa_output
wa_output-ebeln = wa_ekko-ebeln.
wa_output-lifnr = wa_ekko-lifnr.
wa_output-ekorg = wa_ekko-ekorg.
wa_output-aedat = wa_ekko-aedat.
LOOP AT it_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln. " move data from wa_ekpo to wa_output
wa_output-menge = wa_ekpo-menge.
APPEND wa_output TO it_output. " populate the output internal table
ENDLOOP.
ENDLOOP.and in global data I have declared the other internal tables and work areas.
But nothing is printing in the table.
Dev.
‎2010 Feb 05 5:40 AM
As you said, you are fetching data from two internal tables and then collecting it in the final table.
In the Initialization create final internal table type and its work area.
You can also do the data populating process in INITIALIZATION.
Finally in the table,within the DATA tab, provide the internal table name it_final and its work area wa_final.
‎2010 Feb 05 5:40 AM
Hi,
You can also add the loop statements in the initialization area or
if there is an requirement of loop inside loop then you can add program
lines in your flow logic.
Hope it helps
Regards
Mansi
‎2010 Feb 05 5:43 AM
hi,
for selecting data write code in
global definitions -> initialization,
mention the input and output parameters.
when you create the table
then in the data tab
write the code internal table and work area,
n for loop inside loop you will have to create a programming line.
if there is only one loop for passing data from internal table to work area.
you do not require the programming line.
just mention it in the data tab.
‎2010 Feb 05 6:03 AM
Thanks everyone for the response.
Actually in form interface -> import I have declared lv_ebeln for which I have to display the purchase order details.
In Initilization I have written the below code.
TABLES: ekko, ekpo.
DATA: lv_ebeln TYPE ekko-ebeln.
DATA: it_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.
SELECT ebeln lifnr ekorg aedat
FROM ekko
INTO TABLE it_ekko
WHERE ebeln = lv_ebeln.
IF sy-subrc = 0. " If values are fetched into it_ekko then fetch the values into it_ekpo
SELECT ebeln menge
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
LOOP AT it_ekko INTO wa_ekko. " move data from wa_ekko to wa_output
wa_output-ebeln = wa_ekko-ebeln.
wa_output-lifnr = wa_ekko-lifnr.
wa_output-ekorg = wa_ekko-ekorg.
wa_output-aedat = wa_ekko-aedat.
LOOP AT it_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln. " move data from wa_ekpo to wa_output
wa_output-menge = wa_ekpo-menge.
APPEND wa_output TO it_output. " populate the output internal table
ENDLOOP.
ENDLOOP.and in global data I have declared the other internal tables and work areas.
But nothing is printing in the table.
Dev.
‎2010 Feb 05 6:07 AM
Hi,
If you have declared lv_ebeln in form interface then there's no need to declare it again in INITIALIZATION.
Check if you have mentioned the inpuT and output parameters in the INITIALIZATION.
Edited by: Radhika Parag Rajopadhye on Feb 5, 2010 7:08 AM
‎2010 Feb 05 6:09 AM
hi,
i did some change in your code.
check if it works.
TABLES: ekko, ekpo.
DATA: lv_ebeln TYPE ekko-ebeln.
DATA: it_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.
SELECT ebeln lifnr ekorg aedat
FROM ekko
INTO TABLE it_ekko
WHERE ebeln = lv_ebeln.
IF sy-subrc = 0. " If values are fetched into it_ekko then fetch the values into it_ekpo
SELECT ebeln menge
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
LOOP AT it_ekko INTO wa_ekko. " move data from wa_ekko to wa_output
wa_output-ebeln = wa_ekko-ebeln.
wa_output-lifnr = wa_ekko-lifnr.
wa_output-ekorg = wa_ekko-ekorg.
wa_output-aedat = wa_ekko-aedat.
*CHECK THIS CODE*
read table it_ekpo INTO wa_ekpo WHERE ebeln = wa_ekko-ebeln. " move data from wa_ekpo to wa_output
wa_output-menge = wa_ekpo-menge.
APPEND wa_output TO it_output. " populate the output internal table
ENDLOOP.
if you declared lv_ebeln in driver program then mention in form interface.
if you declared it in smartform then do it in global definition.
‎2010 Feb 05 6:17 AM
Hi,
But if I dont declare it in initilization it is throwing an error global data : lv_ebeln is unknown.
In input and output parameters I have given
Input parameters output parameters
IT_EKKO IT_EKKO
WA_EKKO WA_EKKO
IT_EKPO IT_EKPO
WA_EKPO WA_EKPODev.
‎2010 Feb 05 6:20 AM
hI,
Declare another variable lv_ebeln1 in initialization and
store value of lv_ebeln in it.
Have you mentioned it_output and wa_output in the output parameters ?
‎2010 Feb 05 6:42 AM
Hi Radhika,
SELECT ebeln lifnr ekorg aedat
FROM ekko
INTO TABLE it_ekko
WHERE ebeln = lv_ebeln.I have seen in debugging. This select is not fetching any data though the where condition is satisfied. What might be the reason? Please help me.
‎2010 Feb 05 6:45 AM
Hi,
Have you checked the value of lv_ebeln in the debugger?
Is it coming from the driver program or not?
‎2010 Feb 05 6:57 AM
Hi Radhika,
I have not written any report to call this smartform. I am directly executing it. Yes in the dubugging lv_ebeln is not having any value. Will it not take the value if we dont create a driver program? I dont want to create a report program for this. I want to directly execute from smartform only. Cant we do like that?
BTW thanks for your continues help.
Dev.
‎2010 Feb 05 7:02 AM
Hello
It is always better to write a driver program. I driver program, you can do the data fetching part and then by
passing the internal tables through form inerface you just display the data in the msart form
If you do not want to write driver program, then you must provide some value to lv_ebeln. Otherwise no
records will be fetched. And second thing, if you are not using driver program, then you need not write lv_ebeln
in the form inteface since form interface is the place to declare varables ,tables coming from the driver program .
‎2010 Feb 05 7:22 AM
Thanks Radhika.
I have removed lv_ebeln from form interface. Declared it in Global Definition and defaulted it with a value. Now I am getting the output.
Thanks again. thank you very much for spending your time to solve others problems .
‎2010 Feb 05 6:07 AM
Hi,
Have Created Line Type for the Table?
And with in the same Table of Loop node you need to use created line type.
And all the fields in the rowtype, should have the variables which will have the data for every interation.
Thanks & Regards,
vamsi.