Passing internal table with the subroutines
hi experts,
cud u plz tell me how to pass two internal tables in a perform ,form statement plz make me understand with the help of simple logic....actually i have to subtract the data of current month to the data of previous month depending upon the number of months on selection screen...........thnx in advance....sud i apply some other logic for this........
Hi
DATA: BEGIN OF line,
num1 TYPE i,
num2 TYPE i,
END OF line.
DATA itab LIKE STANDARD TABLE OF line.
PERFORM fill CHANGING itab.
PERFORM out USING itab.
FORM fill CHANGING f_itab LIKE itab.
DATA f_line LIKE LINE OF f_itab.
DO 3 TIMES.
f_line-num1 = sy-index.
f_line-num2 = sy-index ** 2.
APPEND f_line TO f_itab.
ENDDO.
ENDFORM.
FORM out USING value(f_itab) LIKE itab.
DATA f_line LIKE LINE OF f_itab.
LOOP AT f_itab INTO f_line.
WRITE: / f_line-num1, f_line-num2.
ENDLOOP.
ENDFORM.
Regards,
S.Suresh.
Rewards if Useful.
Similar Messages
-
How to create an dynamic internal table with the structure of a ddic table
Hi all,
I want to fill ddic-tables (which I already created) in my abap dictionary with data out of CSV-files (which are located on the CRM-Server). The ddic tables have different amount of fields.
I started with creating a table which contains the name of the tables and the path to the matching CSV-file.
At the beginning I'm filling an internal table with part of this data (the name of the ddic-tables) - after that I am looping at this internal table.
LOOP AT lt_struc ASSIGNING <lfs_struc>.
LOOP AT lv_itab1 INTO lv_wa1 WHERE ztab_name = <lfs_struc>.
lv_feld = lv_wa1-zdat_name.
ENDLOOP.
CONCATENATE 'C:\-tmp\Exportierte Tabellen\' lv_feld INTO lv_pfad.
Do.
OPEN DATASET lv_pfad FOR INPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.
READ DATASET lv_pfad INTO lv_rec.
IF sy-subrc NE 0.
EXIT.
ENDIF.
enddo.
REPLACE ALL OCCURRENCES OF '"' IN lv_rec WITH ''.
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
INSERT into (<lfs_struc>) values lr_str_value.
CLOSE DATASET lv_pfad.
endloop.
This is not the whole code, but it's working until
SPLIT lv_rec AT ';' INTO TABLE lt_str_values.
I want to split all the data of lv_rec into an internal table which has the structure of the current ddic-table, but I didn't find out how to do give the internal table the structure of the ddic-table. In the code I used an internal tyble type string but I should be the structure of the matching tabel.
If I try to create an internal table by using a fiel symbol, I am told, that the data types are not matching.
Has anyone an idea?Hi Mayari,
though you were successfull with
METHOD cl_alv_table_create=>create_dynamic_table
I must warn you not to use it. The reason is that the number of tables created is limited, the method uses GENERATE SUBROUTINE statement and this triggers an unwanted database commit.
If you know the DDIC structure, it is (starting with ECC6.0) much easier:
field-symbols:
<table> type standard table.
data:
lr_data type ref to data.
Create data lr_data type table of (<DDIC structure>).
assign lr_data->* to <table>.
The split code can be simplified gaining speed loosing complexity not loosing functionality.
field-symbols:<fs_s> type any.
field-symbols:<fs_t> type any.
SPLIT lv_rec AT ';' INTO table it_string.
loop at it_string assigning <fs_s>.
assign component sy-tabix of wa_string to <fs_t>.
if sy-subrc = 0.
<fs_t> = <fs_s>.
endif.
at last.
append <fs_itwa3> to <ft_itab3>.
endat.
endloop.
Though it may work as Keshav.T suggested, there is no need to do that way.
Regards,
Clemens -
Dynamic Internal Table with the same name
Hey Guys
I have a question.
I know that we can create dynamic internal table taking a struct dynamically.
But I have 2 ques on the same subject.
1. Can we create an internal table based on a type that we have locally declared eg
types: begin of ty_demo.
var1(1) type c,
var2 type p,
end of ty_demo.
2. If an internal table is already declared based on the above type say data: i_tab type standard table of ty_demo.
If i need to enhance the struct of this internal table. Can i do that by dynamically redefining it based on a different structure but keepin the same name i_tab.
In a nut shell I cannot change the name of my itab but I want to enhance the structure.
I Hope I am clear.
Help will be greatly apprcieated.
Thanks
Sameerhai.
we can create an internal table based on a type that we have locally declared, but you have to use data instead of types like.
data: begin of ty_demo.
var1(1) type c,
var2 type p,
end of ty_demo.
check the example notes for dynamic itab .
Dynamic internal table is internal table that we create on the fly with flexible column numbers.
For sample code, please look at this code tutorial. Hopefully it can help you
Check this link:
http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
Sample code:
DATA: l_cnt(2) TYPE n,
l_cnt1(3) TYPE n,
l_nam(12),
l_con(18) TYPE c,
l_con1(18) TYPE c,
lf_mat TYPE matnr.
SORT it_bom_expl BY bom_comp bom_mat level.
CLEAR: l_cnt1, <fs_dyn_wa>.
Looping the component internal table
LOOP AT it_bom_expl INTO gf_it_bom_expl.
CLEAR: l_cnt1.
AT NEW bom_comp.
CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
For every new bom component the material data is moved to
temp material table which will be used for assigning the levels
checking the count
it_mat_temp[] = it_mat[].
Component data is been assigned to the field symbol which is checked
against the field of dynamic internal table and the value of the
component number is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
<fs_check>.
<fs_check> = gf_it_bom_expl-bom_comp.
ENDAT.
AT NEW bom_mat.
CLEAR l_con.
ENDAT.
lf_mat = gf_it_bom_expl-bom_mat.
Looping the temp internal table and looping the dynamic internal table
*by reading line by line into workarea, the materialxxn is been assigned
to field symbol which will be checked and used.
LOOP AT it_mat_temp.
l_nam = c_mat.
l_cnt1 = l_cnt1 + 1.
CONCATENATE l_nam l_cnt1 INTO l_nam.
LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
ENDLOOP.
IF <fs_xy> = lf_mat.
CLEAR lf_mat.
l_con1 = l_con.
ENDIF.
Checking whether the material exists for a component and if so it is
been assigned to the field symbol which is checked against the field
of dynamic internal table and the level of the component number
against material is been passed to the dynamic internal table field
value.
IF <fs_xy> = gf_it_bom_expl-bom_mat.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
CLEAR l_con.
MOVE gf_it_bom_expl-level TO l_con.
CONCATENATE c_val_l l_con INTO l_con.
CONDENSE l_con NO-GAPS.
IF l_con1 NE space.
CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
CLEAR l_con1.
l_cnt = l_cnt - 1.
ENDIF.
<fs_check> = l_con.
l_cnt = l_cnt + 1.
ENDIF.
ENDLOOP.
AT END OF bom_comp.
At end of every new bom component the count is moved to the field
symbol which is checked against the field of dynamic internal table
and the count is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
<fs_check> = l_cnt.
INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
ENDAT.
ENDLOOP.
regards.
sowjanya.b -
How to pass internal table with data in ABAP OO
Hi experts ,
Here is the problem...
I create a screen 100 and use the internal table to get data from database, and then press the button on screen 100 , it will call screen 200.
I use ABAP OO code in screen 200, and i want to keep the internal table with data that i get from the sceen 100 parts, but it seems that it just supports to create a new internal table and get data from database in ABAP OO. That means i need to create a new table to save the data in internal table ? Or there is any other solution something like exporting or memory id ...
ps . the internal table in screen 100 is declared in global area, the beginning of the code.
Please give me some advice, thanks a lot!
Regards ,
ClaireI have already know how to do, here is my code:
METHODS fill_tree importing itab2 like itab1.
CALL METHOD: me->fill_tree exporting itab2 = itab1.
In METHOD fill_tree,
declare
data: itab3 TYPE STANDARD TABLE OF itab,
itab3[] = itab1[].
It is useful to me, thanks a lot. -
Create an internal table with the rows of another internal table.
Hi I want to know if posible to create an internal table structure with the rows of another internal table?
ex.
If in i_tab column A has this values: row 1 = first, row 2 = second, row 3 = third.
Now I want that the structure of my internal table be: first, second, thirdHi,
If you do this way then what will be the difference between the two table anyway?? First internal table has the same structure irrespective of which row you select. and you are going to store the data from each row to the rows of the second internal table. In that case, the structure of the internal table is the same as first table. and it would have same rows.
Am I missing something here? or you want to declare the internal table with each field being the structure of the first table? In this case you'd have to do a dynamic declaration of data as the first table can have any no of rows then the second table would have any no of fields in the structure.
Now if you know that your first internal table is going to have a fixed no of rows eg 3 rows then it becomes simple. Do the following then
Data: begin of second_table occurs 0,
first type <first_table type>,
second type <first_table type>,
third type <first_table type>,
end of second_table.
Regards
Prasenjit -
Passing internal table with a field of type string to & from BAPI
Hello ABAP gurus,
I have a simple BAPI which has to send back an internal table.
Internal table structure is as follows
DATA: BEGIN OF itab OCCURS 0,
config_id(8),
blobdata like zstring,
END OF itab.
where zstring is a string of variable length.
When I try to activate the BAPI I get a message
"itab" must be a flat structure. You cannot use internal tables, strings, references or structures as components.
However, just for testing, I changed blobdata to type of char and I can successfully activate and use the BAPI.
But, our requirement is to pass a string of variable length.
How can I resolve this issue? I have searched sdn and other blogs but didn't help so far.
Any feedback on this will be highly appreciated.
Thanks
RamHi Prasad ,
Try this way :
Acc to your requirement ,create a structure with a parameter and a string , create a table type for that structure .
use that table type in the changing parameter as you need that bapi to accept and return a table .
for the below example , ZTEST_05 is a structure , ZTT_TEST_05 is a table type of ZTEST_05 .
ZTEST_05 has got 2 fields , one is a param of type char(8) and another is a string of type STRING .
I created the below mentioned BAPI and I was able to activate it without any errors .
FUNCTION ZTEST_BAPI_ITAB_01.
""Local Interface:
*" IMPORTING
*" VALUE(BAPI_P1) TYPE ZTEST_05
*" CHANGING
*" VALUE(BAPI_CP1) TYPE ZTT_TEST_05
ENDFUNCTION.
Revert if any issues .
Regards,
Ranjita -
Check the range of values of an internal table with the statement IN
Hi,
I'd like to know how to check if the current contents of a field are in the set described by an internal table.
I know I have to use the statement <b>IN</b>, but I don't know exactly how to define the internal table. In my case, I have a single field (<i>tipo_doc</i>) in my internal table which stores 4 different values: C, I, K, L.
I want to use the statement <b>IN</b> as shown next:
SELECT * FROM VBFA APPENDING CORRESPONDING FIELDS OF TABLE it_flujo_docs WHERE ( VBELN = it_total_fact-vbeln )
AND ( VBTYP_V <b>IN</b> itab).
Then I'd like to know how the internal table <i>itab</i> should be defined. It should be something like this I think, but it doesn't work:
DATA: BEGIN OF itab OCCURS 0,
tipo_doc LIKE zpedidos-tipo_doc,
tipo_doc-sign = 'I',
tipo_doc-option = 'EQ',
tipo_doc-low = C,
tipo_doc-high = L,
END OF it_tipo_doc_ped.
I'd appreciate if someone could tell me the proper way to define it.
Thanks in advance,
GerardHi,
Please follow this.
RANGES R_VBTYP FOR VBFA-VBTYP_V.
R_VBTYP-SIGN = 'I'.
R_VBTYP-OPTION = 'EQ'.
R_VBTYP-LOW = 'C'.
CLEAR R_VBTYP-HIGH.
APPEND R_VBTYP.
Do the same for value 'I', 'K' and 'L'.
Now in the SELECT statement replace the following
VBTYP_V IN itab
with
VBTYP_V IN R_VBTYP.
Thanks
Vinod -
Validate the data in the internal table with the date in selection screen
Hi all,
I want to validate the data in the internal table and get only the records with the input date in the selection screen.
The date is in the select options and please let me know how to get the records only if it satisfies the input date in the selection screen.
Regards,
ShalemFor Ex.
SELECT-OPTIONS: S_DATE FOR VBAK-VDATU
If you want to read one INTERNAL TABLE record
READ TABLE it_tab(internal table name) WHERE vdatu(date field name in the internal table) = s_date
If you want to move more then one
LOOP AT it_tab WHERE vdatu = s_date.
Take the field values in another table and append it. then end loop.
you will get the records which only have the date in select option..
If you want detail code give me internal table name and select option name i will write you the code.
regards
Yuvaram -
Internal table with the filtered ALV records ?
Hi friends,
I have a standard ALV showing for example 10 lines. After using standard filter ALV option,
I only have 5 lines. Is there any internal table where I have these 5 displayed lines ?
Or how could I get them ?
thanksHi,
You can use FM 'REUSE_ALV_GRID_LAYOUT_INFO_GET', like this:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_user_command = 'USER_COMMAND'
tables
t_outtab = data_tab
form user_command using r_ucomm like sy-ucomm s_selfield type slis_selfield.
refresh i_filtered.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
ET_FILTERED_ENTRIES = i_filtered
EXCEPTIONS
OTHERS = 1.
loop at data_tab.
read table i_filtered with key = sy-tabix transporting no fields.
if sy-subrc NE 0.
* Line of data_tab is visible
endif.
endloop.
ENDFORM.
In the I_FILTERED table are the records of data_tab that are NOT visible (are filtered).
Best regards,
Leandro Mengue -
Upload data to an internal table with Services of the Table Tool
Hi,
I'm trying to upload data to an internal table with the table with the new abap debugger but I can see the option in Services of the Table Tool. I see the information in this sap link and also I saw some screen shot in other pages.
http://help.sap.com/saphelp_nw70ehp2/helpdata/en/49/2db60934e414d0e10000000a42189b/content.htm
Is this option depends the SAP version or the patch version or I need to configure the debugger?Hi,
I used the statement
SPLIT i_file AT '|' INTO TABLE It_file.
But it is overwriting each row but not appending to the internal table while passing do and enddo.
Actually my requirement is download the pipe delimited text file and sent an XLS attachment to the
distribution mail id's.
I know sending the mails by using the FM.
But I need all data from the file line by line and pass to the Mail sending function module.
Can you help me in acheiving this.
Regards
Jay -
PASSING INTERNAL TABLR FROM ONE SUBROUTINE TO OTHER SUBROUTINE
hi i want to pass one internal table to other subroutine like this
form abc
data: begin of itab occurs 0.
end of itab
perform xyz tables itab.
endform.
form xyz tables itab like itab[].
end form
it is giving and error that itab is not defiend by data statement
and also tell how to pass two internal tables to the subroutine
thanx in advance
its very urgent
points wil be rewarded
plz help its very urgentHi,
Check this Example
PROGRAM FORM_TEST.
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE STANDARD TABLE OF LINE WITH HEADER LINE,
JTAB TYPE STANDARD TABLE OF LINE.
PERFORM FILL TABLES ITAB.
MOVE ITAB[] TO JTAB.
PERFORM OUT TABLES JTAB.
FORM FILL TABLES F_ITAB LIKE ITAB[].
DO 3 TIMES.
F_ITAB-COL1 = SY-INDEX.
F_ITAB-COL2 = SY-INDEX ** 2.
APPEND F_ITAB.
ENDDO.
ENDFORM.
FORM OUT TABLES F_ITAB LIKE JTAB.
LOOP AT F_ITAB.
WRITE: / F_ITAB-COL1, F_ITAB-COL2.
ENDLOOP.
ENDFORM.
Regards,
Satish -
How to pass internal table to method of class
Hi all,
I am new to abap objects, i want to pass one internal table to class.
i am trying in this way.
class c1 definition.
method get_material importing t_stpo type any table
exporting t_mast type any table.
endmethod.
endclass.
class c1 implementation.
method get_material.
select f1 f2 f3 from <tab> into table t_mast
for all entries in t_stpo
where stlnr = t_stpo-stlnr.
endmethod.
endclass.
ERROR:
"stlnr" is not available
if i use this way. its not giing error.
class c1 definition.
method get_material exporting t_mast type any table.
endmethod.
endclass.
class c1 implementation.
method get_material.
select f1 f2 f3 from <tab> into table t_mast
for all entries in it_stpo
where stlnr = it_stpo-stlnr.
endmethod.
endclass.
how to pass internal table with some specific reference may be using like or type <it_xxxx>
thanksTry this.
TYPES : BEGIN OF ty_stpo,
stlnr TYPE stpo-stlnr,
idnrk TYPE stpo-idnrk,
menge TYPE stpo-menge,
END OF ty_stpo,
BEGIN OF ty_mast,
matnr TYPE mast-matnr,
werks TYPE mast-werks,
stlnr TYPE mast-stlnr,
END OF ty_mast,
tt_stpo TYPE TABLE OF ty_stpo,
tt_mast TYPE TABLE OF ty_mast.
DATA : it_stpo TYPE tt_stpo,
it_mast TYPE tt_mast.
* CLASS c1 DEFINITION
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS : get_bom_numbers EXPORTING ex_stpo type tt_stpo,
get_parent_material IMPORTING im_stpo TYPE tt_stpo
EXPORTING ex_mast TYPE tt_mast.
endclass.
* CLASS c1 IMPLEMENTATION
CLASS c1 IMPLEMENTATION.
METHOD get_bom_numbers.
ENDMETHOD. "get_bom_numbers
METHOD get_parent_material.
ENDMETHOD. "get_parent_material
START-OF-SELECTION.
DATA : obj TYPE REF TO c1.
CREATE OBJECT obj.
CALL METHOD obj->get_bom_numbers
IMPORTING
t_stpo = it_stpo.
CALL METHOD obj->get_parent_material
EXPORTING
im_stpo = it_stpo
IMPORTING
ex_mast = it_mast.
Regards,
Rich Heilman -
To Load data to internal Table from the spoolrequest
HI All,
I'm trying to load a data to the internal table with the reference of spoolrequest generated by the programme during background process. Can anyone help me.
Regards,
S.JANANIhttp://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO. -
How to create an internal table with a types structure?
Hi experts,
I've 3 internal tables with the same structure, I think I could put a type structure and put that type inside the body of the internal data, is this possible? If true, how can I put that?
Example:
TYPES: Begin of type_s,
pernr like pa0001-pernr,
end of type_s.
Data: begin of itab_1 occurs 0,
¿¿¿??? reference to type_s
end of itab_1.
Thanks a lot,
Regards,
RebecaHi,
Use like this..
DATA: Begin of type_s,
pernr like pa0001-pernr,
end of type_s.
DATA: BEGIN OF ITAB_1 OCCURS 0.
INCLUDE STRUCTURE type_s.
DATA: END OF ITAB_1.
Otherwise like this.
types: Begin of type_s,
pernr like pa0001-pernr,
end of type_s.
Data: itab_1 type standard table of type_s.
Note: You have to create work area explicitly.
Like this
data wa like itab1.
Edited by: Velangini Showry Maria Kumar Bandanadham on May 26, 2009 1:04 PM -
Populating dynamic internal table with data
Hi,
I have an internal table with the data like the below
profit lineId amount
center
s21 70 1000
s21 80 1200
s22 70 800
In the above internal table the number of distinct lineIDs will be vary based on selection-screen creiteria.
So for this I build a fieldcatalog and dynamic internal table like the following
The data available in the above internal table should be placed into the dynamic internal table like the following.
profit
center LineID70 LineID80 .....etc
S21 1000 1200
S22 800
Can any one suggest how to proceed?
Thanks in advance
Nanda.Hi
This is my first ever reply so I hope this works or gives you some ideas.
DATA: l_idcount TYPE i,
l_idvalue LIKE itab2-amount.
*loop through the source internal table
LOOP AT itab1.
* increment count of id numbers in current profit center
l_idcount = l_idcount + 1.
* run through the amount fields in target internal table
DO ID_number TIMES VARYING l_idvalue
FROM itab2-LineID70 NEXT itab2-LineID80.
IF sy-index EQ l_idcount.
* change field value if id count same as field position
l_idvalue = itab1-amount.
ENDIF.
ENDDO.
AT END OF profit_center.
itab2-profit_center = itab1-profit_center.
APPEND itab2.
CLEAR l_idcount.
ENDAT.
ENDLOOP.
ID_number is the number of ids as a result of selection-screen criteria.
Maybe you are looking for
-
Architectural Difference between Oracle 8i and Oracle 9i
hello there anybody can tell me precisely what is the architecture difference in Oracle 8i and Oracle 9i. or provide me the link where i can get it. waiting for reply
-
Hello, i bought an iphone 4 more than two years ago from t-mobile austria an asked for an unlock one week ago, now ive got an message that it has been submitted to apple an i have to connect my device to itunes with another sim card. After i had done
-
Hi Experts, We have an adhoc query based on PNP logical database. But client wants to access OM infotypes data using that query. Can you guide me how we can do that? Thanks and Regards, Ashish.
-
HOW DO YOU SET DOCUMENT PROFILE UNDER COLOR MANAGEMENT IN CS4?
When I try to print in CS4 (File>Print>Color Management >Document(it displays sRGB IEC61966 -2.1) I need to change this to Adobe RGB1998 and I cannot find out how to do this! If I go to >EDIT>COLOR SETTINGS the Working Space shows Adobe RGB 1998. Is
-
CUCILync for Outlook 2010 64-bit
Hello, Is there any possibility or work-arround to integrate the Cisco UC Integration for Microsoft Lync plugin (Release 8.5(1)) with Microsoft Outlook 2010 64-bit? According to the release notes, the "click-to-call" feature it is not supported in Ou