Internal table in OO method
Hi,
I am new to ABAP Objects, and I am trying to implement a Business Add-Inn. I have created a new method, where I define an internal table and then use a function to read data and store it.
The problem is, the function ends correctly, and while debugging I can see that the internal table (i_1001) has data. But after the exception check, the program jumps the LOOP instruction and goes directly to the next instruction. What can the problem be?
I am writing the code in case it helps:
DATA : d_evento TYPE HRTEM_INTEZW-eveid,
d_fecha TYPE HRTEM_INTEZW-adate,
d_linea_1001 TYPE p1001,
d_tipo_evento TYPE objec-objid,
t_l_objeto TYPE STANDARD TABLE OF HROBJECT INITIAL SIZE 1,
t_objeto TYPE HROBJECT.
TYPES : i_tabla_1001 TYPE STANDARD TABLE OF P1001 INITIAL SIZE 0.
DATA: i_1001 TYPE i_tabla_1001.
Inicialización de variables locales.
CLEAR : d_linea , d_num_lineas , d_evento, d_fecha , d_linea_1001, d_tipo_evento.
REFRESH : i_1001 . CLEAR : i_1001.
break-point.
Se busca el tipo de evento al que está vinculado el evento, para
obtener la tipología del evento (que hereda del tipo evento).
REFRESH t_l_objeto.
CLEAR t_objeto.
t_objeto-plvar = '01'.
t_objeto-otype = 'E'.
t_objeto-objid = me->evento.
APPEND t_objeto TO t_l_objeto.
CALL FUNCTION 'RH_READ_INFTY'
EXPORTING
AUTHORITY = 'DISP'
WITH_STRU_AUTH = 'X'
INFTY = '1001'
ISTAT = '1'
BEGDA = d_fecha
ENDDA = '99991231'
TABLES
INNNN = i_1001
OBJECTS = t_l_objeto
EXCEPTIONS
ALL_INFTY_WITH_SUBTY = 1
NOTHING_FOUND = 2
NO_OBJECTS = 3
WRONG_CONDITION = 4
WRONG_PARAMETERS = 5
OTHERS = 6
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN '1'.
MESSAGE 'Infotipos con subtipo especificado al leer inf1001'
TYPE 'E'.
WHEN '2'.
MESSAGE 'No hay datos para la selección del inf 1001'
TYPE 'E'.
WHEN '3'.
MESSAGE 'La tabla de objetos está vacía al leer el inf 1001'
TYPE 'E'.
WHEN '4'.
MESSAGE 'Condición errónea el leer el inf 1001' TYPE 'E'.
WHEN '5'.
MESSAGE 'Parámetros erróneos el leer el inf 1001' TYPE 'E'.
WHEN OTHERS.
MESSAGE 'Error al leer el inf 1001' TYPE 'E'.
ENDCASE.
ENDIF.
LOOP AT i_1001 INTO d_linea_1001 WHERE RSIGN = 'A' AND RELAT = '20' .
d_tipo_evento = d_linea_1001-sobid.
CLEAR d_linea_1001.
ENDLOOP.
me->tipo_evento = d_tipo_evento.
REFRESH t_l_objeto.
It jumps from the IF control of exceptions to the last instruction (REFRESH t_l_objeto). sy-subrc gets the value 4 while it jumps.
Any idea about what can the problem be?
Thanks in advance.
Nerea.
Hi,
In ur code, just try the following in the loop..endloop.
LOOP AT i_1001 INTO d_linea_1001.
d_tipo_evento = d_linea_1001-sobid.
CLEAR d_linea_1001.
ENDLOOP.
me->tipo_evento = d_tipo_evento.
Now, if the loop block works and subrc value is zero, the problem is with the WHERE condition in your loop statement.
Try and revert back.
Reward if helpful.
Regards
Similar Messages
-
Passing internal table to a method of a Global Class
Hi All,
I have to pass a Select option (SO_RANGE) as a IMPORT parameter to a method of a global Class (while calling that method from a executable program).
what Reference type should I give, while defining the IMPORT parameter for that method of class.
SO_RANGE have structure of type (SIGN, OPTION, LOW and HIGH)
Regards,
Pankaj.You first need to define a type for range.
for that goto->public section of your class and put following under TYPES
TYPES : tr_matnr type range of mara-matnr .
now you can use this tr_matnr in global class to define input parameter and in your program to define a variable .
In your program define variable as
DATA data_mat TYPE Classname=>tr_matnr
To define workarea type use following.
TYPES : t_matnr TYPE LINE OF tr_matnr . -
How to pass a internal table used in one method to another method in a view
hi all,
Is it possible to pass a internal table from one method to another method in a view??
If so , kindly help me.Hi Bala,
If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
Regards,
Uday -
How to return an internal table with methods ?
Hi,
I am an Java programmer and very new to ABAP.
How do I return a internal table with a method? I have the table GP1_PRODUCTS and want to return a copy of this table as an internal table called PRODUCTS.
Here is my code that does not work:
class PRODUCTS definition
public
final
create public .
public section.
*"* public components of class PRODUCTS
*"* do not include other source files here!!!
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type GP1_PRODUCTS .
protected section.
*"* protected components of class PRODUCTS
*"* do not include other source files here!!!
private section.
*"* private components of class PRODUCTS
*"* do not include other source files here!!!
ENDCLASS.
CLASS PRODUCTS IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method PRODUCTS->GET_PRODUCT_LIST
* +-------------------------------------------------------------------------------------------------+
* | [<-()] PRODUCTS TYPE GP1_PRODUCTS
* +--------------------------------------------------------------------------------------</SIGNATURE>
method GET_PRODUCT_LIST.
DATA: it_products TYPE STANDARD TABLE OF GP1_PRODUCTS.
select * from GP1_PRODUCTS into table it_products.
PRODUCTS = it_products.
endmethod.
ENDCLASS.You have to create a table type for your table GP1_PRODUCTS.
If you use global class (created in SE24), than:
Create a Table Type in SE11
Go to SE11, Enter a name like ZPRODUCTS in the Data Type
There will be popup when you press the Create button to decide a type. Select the Table Type
Enter GP1_PRODUCTS in the Line Type.
* method declaration
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type ZPRODUCTS.
If you use local class:
TYPES: ty_products type standard table of GP1_PRODUCTS..
* method declaration
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type ty_products
Regards,
Naimesh Patel -
Passing an Internal Table as parameter to a method
Hi,
Can we pass an internal table as a parameter to a method.if so how can we do that?i am new to abap objects..Hi Matt,
Here is the code that i am trying to execute.I am extracting the data in the method "Extract" and passing it to the method "Display" to produce a report output.When i execute this it is giving me an error saying that t_mara is not an internal table since i just refered it with x_mara in the class definition.So how can i modify this code to pass t_mara as an internal table from the method "Extract".Please help me.
*& Report ZOBJ_PRAC *
REPORT zobj_prac .
CLASS example DEFINITION
CLASS example DEFINITION.
PUBLIC SECTION.
TYPES : BEGIN OF x_mara,
matnr TYPE matnr,
ersda TYPE ersda,
END OF x_mara.
METHODS : extract EXPORTING t_mara TYPE x_mara,
display IMPORTING it_mara TYPE x_mara.
ENDCLASS. "example DEFINITION
"example IMPLEMENTATION
CLASS example IMPLEMENTATION
CLASS example IMPLEMENTATION.
METHOD extract.
DATA :lt_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0,
lw_mara TYPE x_mara.
SELECT matnr ersda FROM mara INTO TABLE lt_mara UP TO 10 ROWS.
t_mara[] = lt_mara[].
ENDMETHOD. "extract
METHOD display.
DATA :lt_mara TYPE STANDARD TABLE OF x_mara INITIAL SIZE 0,
lw_mara TYPE x_mara.
lt_mara[] = it_mara[].
LOOP AT lt_mara INTO lw_mara.
WRITE:/ lw_mara-matnr,
20 lw_mara-ersda.
ENDLOOP.
ENDCLASS. "example IMPLEMENTATION
START-OF-SELECTION.
DATA : b1 TYPE REF TO example.
CREATE OBJECT b1 TYPE example.
TYPES : BEGIN OF x_mara,
matnr TYPE matnr,
ersda TYPE ersda,
END OF x_mara.
data : t_mara type standard table of x_mara initial size 0,
it_mara type standard table of x_mara initial size 0.
call method b1->extract
importing
t_mara = t_mara.
it_mara[] = t_mara[].
call method b1->display
exporting
it_mara = it_mara.
Edited by: Sai Chaitanya on Dec 2, 2008 5:30 AM -
Passing a internal table from method
Hi All,
I am using Object Oriented Programming in my program.
I want to pass a Internal Table from a method calling statement written in a start-of-selection.
Can any one give me the syntax for
1. Declaring a method with importing parameter as internal table.
2. Syntax for Method Implementation
3. Syntax for calling the method from start-of-selection.
helpful answers are rewarded.
Regards,
Azaz Ali.Hi,
Calling Method is similar to calling function Module.
CALL METHOD cl_gui_frontend_services=>gui_download
exporting
filename =
IMPORTING
FILELENGTH =
changing
data_tab = <b>( this is ur internal table name )</b>* EXCEPTIONS
FILE_WRITE_ERROR = 1.
<b>In OO ABAP u avoid creating table with header line</b>
Best way to call method is to use <b>PATTERN</b> Button
1) Click Pattern Button
2) Select Abap Object Pattern
3) Enter
4) Select Call Method
5) Enter instance name ( i. e used for create object ) ( No need for static method like gui_download )
6) Enter Class / Interface name
7) Enter Method Name
done.
<b>passing value to method is similar to FM.
Creating internal table for Method
any TYPE ........SAY TY_Intern
Then Syntax Should Be
DATA : OO_INTERNAL_TABLe type table of TY_Intern.
pass this to the Method.
Hope This will solve ur problem.
Please Mark Helpful Answers</b>
Message was edited by: Manoj Gupta -
Performance with internal tables
Hi everybody,
I'm having trouble with the performance of a report.
The reports selects data out of many different tables and merges them together in one extraction file. (I would really like it to be executable in dialog task, because I don't want to write the file on the application sever)
I've done what I could using runtime analysis to improve performance of the db accesses. Now 97% of runtime is consumed by abap.
I'm using several internal tables which will have many entries, and at the moment I'm using nested loops to gather the information out of the internal tables into one extraction file. (Reading the internal tables with key is not always possible, I do this whenever possible)
I've tried to use loop... assigning <fs> instead of loop... into, but it doesn't really help too much.
Any other suggestions?
Thank you for your help, regards, Kathrin!Hi,
Some of these might be able to help for improving the performance.
1. Read table with key using binary search.
2. While comparing two internal tables, user Kernal
method. Eg: If I_TAB1[] = I_TAB2[]. Enfif.
3. Instead of appending records within loop/endloop,
use 'Append lines of'.
4. When populate different internal tables, try to create
with key field which will make a big difference while
accessing the data.
5. Sort the internal tables.
6. Use Case/Endcase in place of If/Endif.
7. While making values negative, use 0 - <field>, in
place of <field> * -1.
8. If the field structures are similar in two internal
tables, for appending records use I_TAB2[] = I_TAB1[].
9. After the complete usage of internal tables, release
the resources using FREE/FREFRESH <internal table>.
10. For data extraction, use field by field selection
from database.
11. Try to avoid using 'ALL ENTRIES'. If using and make
sure that the ref.internal table have entries.
12. Try using Inner Join using Foriegn key fields.
13. To get sum or count use Aggregate functions.
14. Try to use Views if need appropriately.
Hope this helps.
Gopakumar -
Exporting internal table in a oops
hi friends,
I have to pass internal table to a method and export that internal table.
now when i am passing this internal table i am getting the last value of the table..
i am enclosing code here please go through and modify me regarding this..
REPORT ZTEST_ABAP_PROXY.
DATA PRXY TYPE REF TO ZCO_MI_PROXY_OUTBOUND.
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
ERNAM LIKE MARA-ERNAM,
END OF I_MARA.
CREATE OBJECT PRXY.
DATA IT TYPE ZMT_PROXY_OUTBOUND OCCURS 0 WITH HEADER LINE.
TRY.
SELECT MATNR ERNAM INTO TABLE I_MARA FROM MARA UP TO 10 ROWS.
LOOP AT I_MARA.
IT-MT_PROXY_OUTBOUND-MATNR = I_MARA-MATNR.
IT-MT_PROXY_OUTBOUND-ERNAM = I_MARA-ERNAM.
APPEND IT.
ENDLOOP.
CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
EXPORTING
OUTPUT = IT.
COMMIT WORK.
CATCH CX_AI_SYSTEM_FAULT .
DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .
CREATE OBJECT FAULT.
WRITE :/ FAULT->ERRORTEXT.
ENDTRY.
i need to pass all the values of internal table to output at once..
Thanks and Regards
VijayHi Vijay,
I think the problem is with the output parameter.
Might be I'll give you the background and then explain you the problem. This may help.
In the older release of ABAP there used to be Tables as one of the tabs where one could import/export tables to/from the FM. The problem was that it would difficult to identify what table are being imported and what are bein exported.
So with later releases of ABAP this tab was removed and currently there are Exporting/Importing/Changing tabs. You can use changing in your case if you are passing the table to modify the same.
Now the problem.
As stated above the OUTPUT is a line type (means structure) while IT is a internal table with header lines. So the record in the wa of this table is only transferred to OUTPUT.
What needs to be done.
You need to change the type of the OUTPUT to table type. I am not sure if you know about table type.
You can create a Table Type is se11 under Data Type.
I hope this helps.
Regards,
Saurabh -
How to use internal table in F4 help?
Hello Experts,
I need to assign F4 help for Employee Responsible ID field in Search Criteria. I'm able to fetch the details of all employees into an internal table in get_v_xyz method of employee res. attribute. My doubt is,Can we display an internal table as F4 help. If yes, How can we do that?
Regards
DNR VarmaHi,
here is the code to be written in GET_V to add itnernal table as search help.
data:
GR_DDLB_DIVISION TYPE REF TO CL_CRM_UIU_DDLB,
data:
ls_value TYPE bsp_wd_dropdown_line,
lt_ddlb TYPE bsp_wd_dropdown_table.
IF gr_ddlb_division IS NOT BOUND.
CREATE OBJECT gr_ddlb_division
EXPORTING
iv_source_type = ''T'.
LOOP AT internal table INTO work area.
ls_value-key = work area-key.
ls_value-value = work area-value.
INSERT ls_value INTO TABLE lt_ddlb.
ENDLOOP.
gr_ddlb_division->set_selection_table( it_selection_table = lt_ddlb ).
endif.
rv_valuehelp_descriptor = gr_ddlb_division.
Thanks
Sudhir Grover -
Hi guys...
How can I import a internal table in a method of Badi?
For example:
I have the itab_ekpo that I export to memory in a especific program and need to import this table.
Hw can I do this in a method ?
tks
flavioHi,
If the table data is filled in same session and BADI is called is in same session then you use simple EXPORT TO MEMORY-ID and IMPORT TO MEMORY-ID statement.
Else if both are done in different session then use EXPORT using INDX table and IMPORT the DATABASE INDX in your BADI.
Please see the F1 documentation for the keyword help.
Regards,
SRinivas -
Add field in an internal table
Hi There,
How to add a field in an internal table created at the runtime using
CREATE DATA D1 TYPE TABLE OF (VAR).
where say var contains name of a DDIC table.
Rgds,
deb.after creating internal table use the method for creation of dynamic table and try , i am not sure
DATA: LineType TYPE string,
ItabRef TYPE REF TO DATA.
FIELD-SYMBOLS: TYPE STANDARD TABLE.
LineType = 'SFLIGHT'.
" Create internal table and attach a field-symbol
CREATE DATA ItabRef TYPE STANDARD TABLE OF (LineType).
ASSIGN ItabRef->* TO .
<b>after this check this and try</b>
******DATA DECLARATION*****************************
FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
<wa_final> TYPE ANY,
<w_field> TYPE ANY.
***DYNAMIC CREATION OF FIELDCATALOG****************
*FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,
*LIKEWISE DYNAMIC FIELDCATALOG IS CREATED
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
LOOP AT it_mandt WHERE mandt IN s_mandt.
CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
wa_fieldcatalog-inttype = 'NUMC'.
wa_fieldcatalog-outputlen = '14'.
wa_fieldcatalog-reptext = it_mandt.
wa_fieldcatalog-seltext = it_mandt.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR :wa_fieldcatalog ,it_mandt.
ENDLOOP.
********CREATE DYNAMIC TABLE************************
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = new_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN new_table->* TO <it_final>.
*********CREATE WORK AREA****************************
CREATE DATA new_line LIKE LINE OF <it_final>.
ASSIGN new_line->* TO <wa_final>.
*********INSERTTING WORK AREAR TO INTERNAL TABLE******
INSERT <wa_final> INTO TABLE <it_final>.
*******POPULATING DATA*******************************
LOOP.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '21453DD'.
FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
ENDLOOP.
ENDLOOP. -
How to pass a internal table into Java Bean
Hi Experts,
I created a JSPDyn page to display Sales orders form R/3 using bapi_sales_order_getlist.
I used JCO to establish connectivity between JSP Dynpage and R/3. I executed the bapi successfully, i want to move the sales orders retrieved from the Bapi to a Java Bean. So that i can use the bean to populate the value as a table.
with regards,
James.
Valuable answers will be rewarded.....Hi Bala,
If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
Regards,
Uday -
Dynamic ALV Internal table Problem
Hi all,I have successfully built an IT using method 'create_dynamic_table'.But my problems are :
1)When Iam trying to select the data with multiple tables then it is short dumping.
2)I tried to oselect the data using one table,after selecting the data if I use FM REUSE_ALV_Grid_Display then it is showing short dump with error 'type conflict when calling FM'.
I never used field symbols before.PLZ complete my program or give me suffecient feedback.Here is my program :
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data.
DATA : dats LIKE vbbe-mbdat,
t_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>,
<dyn_field>.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR dats.
SELECTION-SCREEN END OF BLOCK blk1.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-seltext = 'Material Number'.
wa_fieldcat-intlen = '18'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MAKT'.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'MBDAT'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'OMENG'.
wa_fieldcat-datatype = 'QUAN'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
DATA : d TYPE i,
v(02) TYPE n VALUE '0',
day(8) TYPE c.
d = s_mbdat-high - s_mbdat-low + 1.
DO d TIMES.
v = v + 1.
CONCATENATE 'Day' v INTO day.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = day.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-seltext = day.
wa_fieldcat-intlen = '8'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
ENDDO.
*-----Building Dynamic internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
SELECT m~werks m~matnr v~omeng v~mbdat INTO CORRESPONDING FIELDS
OF TABLE <it_dyn> FROM mska AS m INNER JOIN vbbe AS v
ON m~posnr = v~posnr WHERE v~mbdat IN s_mbdat.*DATA : d TYPE i,
v(02) TYPE n VALUE '0',
day(8) TYPE c.
*d = s_mbdat-high - s_mbdat-low + 1.
*DO d TIMES.
v = v + 1.
CONCATENATE 'Day' v INTO day.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = day.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-seltext = day.
wa_fieldcat-intlen = '8'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
*ENDDO.
*-----Building Dynamic internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
SELECT OMENG FROM VBBE INTO CORRESPONDING FIELDS OF TABLE <IT_DYN> WHERE MBDAT IN S_MBDAT.
BREAK-POINT.
YOU WILL GET VALUES IN INTERNAL TABLE.
TO SOLVE YOUR ISSUE YOU SHOULD USE NUM INSTEAD OF DATS. -
Accessing Dynamic Internal table fields
Hello All,
I have one internal table ep_tabx having 138 columns whose data is getting displayed
by using function module reuse_alv_grid_display.
Now my query is, i have created one custom button on the appl toolbar to download ep_tabx data.
IF the user changes the the layout of the output at runtime and then presses that custom button
then i have created one dynamic internal table using call method cl_alv_table_create=>create_dynamic_table suppose <dyn_table> whose struc will be that of
dynamic fieldcatalog returned by using FM REUSE_ALV_GRID_LAYOUT_INFO_GET.
And then I have put a loop on the int table ep_tabx and move corresponding to the int table
<dyn_table>. But when i download the <dyn_table> data through GUI_DOWNLOAD the
date fields data is not getting downloaded correctly. I have 4 date fields in my ep_tabx.
In the alv grid output the date is getting displayed like 08/30/2004(ie mon/date/yr) but in download
file it comes like 20040830(ie yr/mon/date and that too without /).How to access the dynamic
internal tables fields separately so asto convert them in the pgm before the download.
Kindly Help.
Thanks in advance.
MansiHi,
Search in SDN you would get loads of info on accessing dynamic itab's .
in order to convert your date format use WRITE stmt to convert the value in your itab before passing it to download FM.
Regards,
Raghavendra -
Dynamic field access in internal tables
Hi everyone.
I woulkd like to know if there is any way to identify the fields of an internal table at runtime. I'm creating a method in a class, and i would like to accept any itab as a paramter and then access the fields of that itab. I currently have the itab passing no problem using field symbols, and i am able to loop at the data, but i am unsure how to get the field names.
Any suggestions?
Thanks!Hi,
Check the code below:
REPORT ZYKTEST3 .
DATA: d_ref TYPE REF TO data,
d_ref2 TYPE REF TO data,
i_alv_cat TYPE TABLE OF lvc_s_fcat,
ls_alv_cat LIKE LINE OF i_alv_cat.
TYPES: tabname LIKE dcobjdef-name ,
fieldname LIKE dcobjdef-name,
desc LIKE dntab-fieldtext.
PARAMETER: p_tablen TYPE tabname. -
> Input table field
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE dntab.
DATA: END OF itab.
FIELD-SYMBOLS : <f_fs> TYPE table,
<f_fs1> TYPE table,
<f_fs2> TYPE ANY,
<f_fs3> TYPE ANY,
<f_fs4> type any,
<f_field> TYPE ANY.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET' -
> Fetches the fields
EXPORTING
langu = sy-langu
tabname = p_tablen
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
LOOP AT itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
ls_alv_cat-seltext = itab-fieldtext.
ls_alv_cat-reptext = itab-fieldtext.
APPEND ls_alv_cat TO i_alv_cat.
ENDLOOP.
internal table build
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_alv_cat
IMPORTING
ep_table = d_ref.
ASSIGN d_ref->* TO <f_fs>. -
> Dynamic table creation with fields of the table
DATA: l_field TYPE fieldname,
l_field1 type fieldname.
SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <f_fs>.
Fetching of the data from the table
LOOP AT <f_fs> ASSIGNING <f_fs2>.
Here u can check the validations and process
ASSIGN COMPONENT 2 OF STRUCTURE <f_fs2> TO <f_fs3>.
ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
IF sy-subrc = 0.
MOVE <f_fs3> TO l_field.
MOVE <f_fs4> TO l_field1.
WRITE:/1 l_field(20),
22 l_field1(10).
ENDIF.
ENDLOOP.
Regards
Kannaiah
Maybe you are looking for
-
Why does Pages 09 hang for 1min30sec? The spinning ball, etc...
I am using Pages 09 version 4.3 (not the iWork package, just Pages 09) Operating system 10.8.3 with 4 Gb memory on an iMac from around 2009 (Intel core 2 duo) I had been using Quark Xpress for a couple decades and wanted to save a book I did in Pages
-
How do I disable an old apple ID so that iCloud can function for me?
I recently enabled a new email address for myself and everything seems to work fine on my Mac and iphone except for icloud. I keep getting messages that pop up asking for my password to my old apple id and it never recognizes it when I put it in. Why
-
I have an old ipod touch which won't go past the Apple logo, all it does is show me a loading symbol, but will go no further, i have tried restoring it and i have been successful. It connects and is recognised by my itunes and computer, but still aft
-
Hello, Inside of the Event Loop Structure is there a way of telling if the event was triggered by a Front Panel change or by the Value Signaling property. I'm thinking I could use the value tabs to the left of the structure (maybe source or type), bu
-
Preview bitmaps on win-explorer-doubleclick
Hi All, on Win7 64 I could with CS5 associate all popular bitmap formats with Bridge. That way when double-clicking an image in windows-explorer I got a preview with Bridge. If so desired I could then fully open that file from the Bridge-Context Menu