Include structure
Hi all
I have this code to give dynamic table name in select statement.
Is there a way the include structure tak in the value from my parameter value like name1?
DATA <b>name1</b>(10) TYPE c VALUE 'ZSTUDGARY'.
DATA: BEGIN OF wa OCCURS 0.
INCLUDE STRUCTURE <b>ZSTUDGARY</b>.
DATA: END OF wa.
SELECT *
INTO wa
FROM (name1) CLIENT SPECIFIED.
WRITE: / wa-eyear, wa-contact.
ENDSELECT.
I think you are looking for somethign like this. Please check this code
REPORT ztest_gopi_dynamic.
TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.
* FORM get_structure *
FORM get_structure.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
ENDFORM.
* FORM create_dynamic_itab *
FORM create_dynamic_itab.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM.
* FORM get_data *
FORM get_data.
* Select Data from table.
SELECT * INTO TABLE <dyn_table>
FROM (p_table).
ENDFORM.
* FORM write_out *
FORM write_out.
* Write out data from table.
LOOP AT <dyn_table> INTO <dyn_wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-index = 1.
WRITE:/ <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM.
Regards
Gopi
Similar Messages
-
What is diff b/w Include Structure and Append Structure at Database Level
Hi Experts,
Could you please let me know what is the main difference between .Include Structure and .Append Structure at SE11?
Thanks in advance and for good answer will give good points.
SekharHi,
1. Append Structures
Append structures can only be assigned to a single table.
Append structures are created in the custome rnamespace ( ZZ or YY)
In case of new versions of the standard table during upgrade, the append structures are automatically appended to the new version of the standard table
Append structures can not be used with cluster and pool tables
Append structures are created in transaction SE11. Display the standard table fields and press the Append structure button.
When you press the button, SAP sugests a name for the new append structure. After you has accepted the name,
a screen will be shown where you can enter the new fields.
Remember to activate.
2. Customizing Includes
Some of the SAP standard tables contains special include statements called Customizing includes. In contrast to Append structures,
Note that customizing includes are created by SAP, but the customer supply the fields for the include.
Customizing includes begin with CI_ and is part of the customer namespace
One Customizing include can be inserted into more than one table.
You can find Customizing includes in SE11 under structures.
Try to take a look at table RKPF which uses the Customizing include CI_COBL (In an IDES system). Next try to add a field to CI_COBL, and activate it. If you go back to table RKPF you will se that your new field has been added.
Regards,
Ferry Lianto -
In a server proxy how can I use a INCLUDE STRUCTURE?
Hi people!!, how can I put an internal table with an INCLUDE statement in a server proxy in abap. If I put the next code the system present me this error: Within classes and interfaces, you can only use "TYPE" to refer to ABAP , Dictionary types, not "LIKE" or "STRUCTURE".
The problem is that I need the STRUCTURE to make a APPEND.
Thanks for the help.
DATA: BEGIN OF bdc_tab .
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdc_tab.Hi Carlos,
Yes. It mainly accepts TYPE statements.
You can use this as:
DATA: BDC_LINE type bdcdata.
DATA: BDC_TAB type table of bdcdata.
When you want to use,
Fill the BDC_LINE.
Then:
Append BDC_LINE to BDC_TAB.
Or:
Loop at BDC_TAB into BDC_LINE.
Cheers,
Bhanu -
Extended syntax check for include structure
Hello Everyone,
While declaring the internal table as:
TYPES: BEGIN OF t_data.
INCLUDE STRUCTURE mara.
TYPES: END OF t_data.
DATA: it_data TYPE table of t_data.
When performing extended check, i get following error:
The current ABAP command is obsolete and problematic, especially so in ABAP
Objects
Within classes and interfaces, you can only use "TYPE" to refer to ABAP Dictionary
types, not "LIKE" or "STRUCTURE".
I am using 4.7 version.
Any clue how to avoid this error during extended check.
Regards,
TarunTarun,
With WAS 6.20 you should not declare internal tables with header line or using the old syntax as they are not compatible with OO ABAP.
So, you either declare a TYPE the way you have done, in case you want additional fields apart from the INCLUDE structure, or declare the table directly like the way I have shown.
Good thing, you can even specify the type of internal table that you want to create using this - STANDARD, SORTED, HASH. These tables will help you with the performance issues.
regards,
Ravi
Note : Please mark the helpful answers -
How do I Make Include Structures Expand Automatically?
As usual some of the simplest things take the longest time.
I've created a custom structure in the dictionary. I've also created a custom table in which I include the structure. I expected that after I added the include structure to the custom table, that it would be expanded and display in se11, and behave just as SAP-delivered tables do. For example, look at table PA0001. There are include lines followed by the contents of the include.
In my custom table though, I only see the include line itself. To see the structure I must expand it by pressing the expand button. Each and every time I display the custom table I must manually expand it. I want the behavior I see on every other SAP table.
Any ideas?
Thank you.
TomHi,
if You have include structure in Your table, all fields are displayed only in display mode.
That is the way You see the PA0001 table.
If You create your own table and include structure, in edit mode You can change fields of the include structure,
that is why it is not expanded. But if You change from edit to display mode, SAP does not expand it automatically.
You should display in SE11 this table - all fields will be visible.
Regards,
Przemysław -
How to include structure in Types Definition ???
Hello All,
I want a declaration like this in BSP :-
DATA : BEGIN OF imkop OCCURS 100.
INCLUDE STRUCTURE mkop.
DATA : waers LIKE mepro-waers.
DATA : END OF imkop.
<b>In BSP: Type Definitions</b>
I wrote like this :-
Types : BEGIN OF imkop.
INCLUDE STRUCTURE mkop.
Types : waers type mepro-waers.
Types : END OF imkop.
I'm getting an error saying that I can't use structures in this .
Now what should I do ?
Can anyone help me out ?
Regards,
Deepu.Kdeepu,
we can declare structures as below.
DATA: event_data TYPE REF TO cl_htmlb_event.
TYPES: BEGIN OF row_iid_type,
row_iid TYPE hap_row_iid,
END OF row_iid_type.
DATA:
t_row TYPE STANDARD TABLE OF row_iid_type,
t_row_wa TYPE row_iid_type,
t_message TYPE STANDARD TABLE OF bal_s_msg .
DATA:
lw_body_element TYPE hap_s_body_elements,
lw_body_column TYPE hap_s_body_columns,
lw_body_cell TYPE hap_s_body_cells,
lw_return TYPE bal_s_msg,
warning TYPE i.
regards,
manasa -
Selection-screen (field from .Include structure)
Hi all,
I have a selection screen with several select-options. One of the select-option is
select-options: s_vornr for afvc-vornr.
Where 'vornr' is a .Include structure field in the table 'afvc'. Now my question is, in selection screen when I click on the box for this particular select-option I dont see the circle(from where we can select the existing input values) at the end of the box.
Why is it so and how can get that circle option at the end of the box by sticking to the same table and field(afvc-vornr).
Waiting for your help.
Thankshi,
the field do not have nay value range with it.
you can put the F4 help by using
At Selection-Screen on Value-request <select-option>. event.
e.g.
DATA : rt_values TYPE STANDARD TABLE OF type_values,
rs_values TYPE type_values,
rt_fields TYPE STANDARD TABLE OF type_fields,
rs_fields TYPE type_fields.
CLEAR : rs_values,rs_fields.
REFRESH : rt_values,rt_fields.
Creation of selection list
rs_fields-tabname = 'AFVC'.
rs_fields-fieldname = 'VORNR
rs_fields-selectflag = ' '.
APPEND rs_fields TO rt_fields.
SELECT vornr form AFVC
INTO TABLE t_vornr.
SORT t_vornr.
DELETE ADJACENT DUPLICATES FROM t_vornr.
LOOP AT t_vornr INTO s_vornr.
rs_values = s_vornr-vornr.
APPEND rs_values TO rt_values.
CLEAR rs_values.
ENDLOOP.
FUNCTION 'HELP_VALUES_GET_WITH_TABLE' EXPORTING
fieldname = 'AFVC'
tabname = 'VORNR
titel = 'Counting
IMPORTING
select_value = <select-opion>
TABLES
fields = rt_fields
valuetab = rt_values.
amit
Message was edited by: Amit Khare -
Infotype and Include Structures in HR - ECC50
Hi,
I would like to know what are the changes in each and every infotype like different include structures or added fields or modified or deleted fields. How do you compare 46C version with ECC50.
Is there any way apart from remote version management option?
Thanks,
Kiran.Hi,
I don't know what your actual requirement is.. but the event GET PAYROLL already exists. PL take a look at the Program EXAMPLE_PNP_GET_PAYROLL to get an idea. You can also see the same at this <a href="http://help.sap.com/saphelp_47x200/helpdata/en/33/62ac39d22d11d396e700a0c9306433/frameset.htm">SAP help</a>
Regards,
Suresh Datti -
Problem with primary/secondary keys in table with included structures
Dear ABAPers,
we have a structure which is supposed to be included in the definition of several tables.
The problem is the following:
depending on the application table that includes this structure, 3 or 4 fields of that structure may
or may not be necessary to enhance the table key. As far as I know included structures can only
completely be marked as keys. Therefore I suggested to split up the structure into two parts,
one part with the possible candidates that may become key fields, and the rest, and of course
a structure that unites both of these substructures. So when it comes to reusing this structure
the developer would have the choice to select the structure with all of the fields in case no field
is needed as additional key, or the developer would have to implement both of the substructures
separately with the option to mark the key-part of it as key in his table.
But unfortunetaly this suggestion of mine was refused as being too complicated and I am supposed
to define all the fields in one flat structure and to "enhance" the primary keys (that always will exist)
by secondary keys.
Does anybody know how that is supposed to work without defining double indexes?
I cannot activate a table without having primary keys defined and any unique secondary index would
allways include all of the primary keys.
Thanks in advance for you help
(I'm sorry that you cannot be granted reward points for just reading the extensive problem description)
regards
AndreasDear Rob,
since your answer was helpful and since it was the only one I will grant you full points on that.
Thanks again for your input. In case other developers should look this thread up being confronted
with the same kind of problem, here is how we solved it:
We added an artificial primary key (a number of type NUMC 8) to the table which is supposed to
include the structure. This key alone takes care of the uniqueness of eacht entry.
All the others fields that we want to have available for a fast direct access, including the ones
from the included structure, are put together in a secondary index.
best regards
Andreas -
Include structure and extra fields in the same Internal Table
Hi developers,
im trying to declare an internal table with include structure and extra fields,
something like this:
data: BEGIN OF it_loans occurs 0,
include structure zthrca006,
status(10),
pernr like pa0001-pernr,
sname like pa0001-pernr,
tipomov(20),
monto like zthrca006-monto,
data: END of it_loans.
zthrca006 is huge so i dont want to type everithing.What is the issue?
data: BEGIN OF it_loans occurs 0.
include structure zthrca006.
data : status(10),
data : pernr like pa0001-pernr.
data : sname like pa0001-pernr.
data : tipomov(20).
data : monto like zthrca006-monto,.
data: END of it_loans.
Regards,
Ravi
Note - Please mark all the helpful answers -
Error on extended check for types include structure statements
Hi All ,
On Extended check im getting error :
Program: ZFIR_VALUATE_OBSOLETE_STOCK Include: ZFIR_VALUATE_OBSOLETE_STOCK_F Row: 1205
The current ABAP command is obsolete
Within classes and interfaces, you can only use "TYPE" to refer to ABAP Dictionary
types, not "LIKE" or "STRUCTURE".
Internal Message Code: MESSAGE G/B
(The message cannot be hidden using pseudo-comment "#EC .., bzw. durch SET
EXTENDED CHECK OFF/ON)
The error is in below line :
TYPES: BEGIN OF t_fttax.
INCLUDE STRUCTURE fttax.
TYPES: END OF t_fttax.
and fttax is a dictionary strucuture . i made internal table and work area using it .
DATA: i_fttax TYPE STANDARD TABLE OF t_fttax,
wa_fttax TYPE t_fttax.
Need Help ,what i should do to remove this error ?
Regardsdeclare as :
DATA: i_fttax TYPE STANDARD TABLE OF fttax,
wa_fttax TYPE fttax.
No need to declare as :
TYPES: BEGIN OF t_fttax.
INCLUDE STRUCTURE fttax.
TYPES: END OF t_fttax. -
Hi,
I'm trying to compile simple construction in ECC 60:
types: begin of t_bbseg.
include structure bbseg.
types: end of t_bbseg.
I have compilation error:
"The type "SI_BBSEG" is unknown"
Is anyone had something like this before?
We are NetWeaver 2004S Unicode enabled.
Thank you,
IharIf you are trying to include BSEG as a structure in the TYPE, use the TYPE keyword instead
types: begin of t_bbseg.
include type bseg.
types: end of t_bbseg.
REgards,
Rich Heilman -
Include structure in smartform
I am trying to define types in smartform Global->Types.
1---types: BEGIN OF tvbdpr1.
INCLUDE STRUCURE vbdpr.----
vbdpr is view
types: END OF tvbdpr1.
it gives error:
"." or "IF FOUND." expected after "STRUCURE".
BUT when i define below there is no error
types: BEGIN OF tkomv1.
INCLUDE STRUCTURE komv.-------it is table
types: END OF tkomv1.
any help thanks
ismailIt was spelling error, thanks
-
Include structure in TYPES declaration
Hello All:
Many forum posts have discussed similar topics, but I couldn't exactly find one answering my requirement. Apologies if I have missed out reading some.
Instead of creating a type as below (as suggested in few forum posts)
TYPES begin of types ty_itab
include type BISEG
xxxx type xxx
xxxx type xxx
End of types ty_itab
I need to create the type with include structure after the additonal fields.
TYPES begin of types ty_itab
<fld1> type <ty1>
<fld2> type <ty2>
include type <struc>
End of types ty_itab
Can someone give the right syntax?
Please help,
Fred.Hello Fred
If you are using the extended syntax you should not encounter any problems:
TYPES: begin of types ty_itab.
TYPES: <fld1> type <ty1>.
TYPES: <fld2> type <ty2>.
include type <struc>.
TYPES: End of types ty_itab
Regards
Uwe -
Syntax error on INCLUDE STRUCTURE.
Hi Experts,
It is abit hard to explain what I need here.
But I try to explain as much as I can.
I am writing this code in order to update the customer material numbers into internal table tvbdpa. As you can see in my code, getting the customer material numbers require mapping the position number.
I am stuck at the LOOP below with ***.
Also getting the syntax error
_The declaration for the key field "KDMAT" is imcomplete.
However "KDMAT" is is contained in the key of table "TVBDPA" and must be filled._
TABLES: vbco3.
DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF tvbdpa OCCURS 0, "Internal table for items
kdmat LIKE LIPS-KDMAT.
INCLUDE STRUCTURE vbdpa.
DATA: END OF tvbdpa.
DATA: itab_vbak TYPE SORTED TABLE OF vbak
WITH UNIQUE KEY vbeln,
wa_vbak LIKE LINE OF itab_vbak,
itab_lips TYPE SORTED TABLE OF lips
WITH UNIQUE KEY vbeln,
wa_lips LIKE LINE OF itab_lips,
wa_tvbdpa LIKE LINE OF tvbdpa,
lv_zuonr TYPE vbak-zuonr.
vbco3-mandt = sy-mandt.
vbco3-spras = nast-spras.
vbco3-vbeln = nast-objky.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdka
TABLES
pos = tvbdpa
mess = da_mess
EXCEPTIONS
fehler_bei_datenbeschaffung = 1.
IF NOT tvbdpa[] IS INITIAL.
SELECT SINGLE zuonr FROM vbak
INTO lv_zuonr
WHERE vbeln = vbdka-vbeln.
IF sy-subrc = 0 AND lv_zuonr <> ''.
SELECT vbeln posnr kdmat FROM lips
INTO CORRESPONDING FIELDS OF TABLE itab_lips
WHERE vbeln = lv_zuonr.
***I am stuck at here.
LOOP AT itab_lips INTO wa_lips.
READ TABLE tvbdpa INTO wa_tvbdpa
WITH TABLE KEY posnr = wa_lips-posnr.
wa_tvbdpa-kdmat = wa_lips-kdmat.
MODIFY TABLE tvbdpa FROM wa_tvbdpa
TRANSPORTING kdmat.
ENDLOOP.
***end I am stuck at here.
ENDIF.
ENDIF.
All advise are welcome and greatly appreciated.
Thanks in advance.Hi Subramanian,
Does this more make sense for you?
Can I read the table like :-
READ TABLE itab_lips INTO wa_lips
WITH TABLE KEY VBELN = wa_tvbdpa-matnr." AND POSNR = wa_tvbdpa-posnr.
TABLES: vbco3.
DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF tvbdpa OCCURS 0, "Internal table for items
kdmat LIKE LIPS-KDMAT.
INCLUDE STRUCTURE vbdpa.
DATA: END OF tvbdpa.
DATA: itab_vbak TYPE SORTED TABLE OF vbak
WITH UNIQUE KEY vbeln,
wa_vbak LIKE LINE OF itab_vbak,
itab_lips TYPE SORTED TABLE OF lips
WITH UNIQUE KEY vbeln,
wa_lips LIKE LINE OF itab_lips,
wa_tvbdpa LIKE LINE OF tvbdpa,
lv_zuonr TYPE vbak-zuonr.
vbco3-mandt = sy-mandt.
vbco3-spras = nast-spras.
vbco3-vbeln = nast-objky.
vbco3-kunde = nast-parnr.
vbco3-parvw = nast-parvw.
CALL FUNCTION 'RV_DOCUMENT_PRINT_VIEW'
EXPORTING
comwa = vbco3
IMPORTING
kopf = vbdka
TABLES
pos = tvbdpa
mess = da_mess
EXCEPTIONS
fehler_bei_datenbeschaffung = 1.
IF NOT tvbdpa[] IS INITIAL.
SELECT SINGLE zuonr FROM vbak
INTO lv_zuonr
WHERE vbeln = vbdka-vbeln.
IF sy-subrc = 0 AND lv_zuonr <> ''.
SELECT vbeln posnr kdmat FROM lips
INTO CORRESPONDING FIELDS OF TABLE itab_lips
WHERE vbeln = lv_zuonr.
LOOP AT tvbdpa INTO wa_tvbdpa.
READ TABLE itab_lips INTO wa_lips
WITH TABLE KEY VBELN = wa_tvbdpa-matnr." AND POSNR = wa_tvbdpa-posnr.
wa_tvbdpa-kdmat = wa_lips-kdmat.
MODIFY TABLE tvbdpa FROM wa_tvbdpa
TRANSPORTING kdmat.
ENDLOOP.
ENDIF.
ENDIF.
Maybe you are looking for
-
Profit center report picks production variance posting from prev periods
(This is a repost, from a ill-chosen forum) Guys I am lost I am running S_ALR_87013340 : profit center Plan Actual comparison report, on a group of profit centers: the total I got is different from the sum of the individual profit centers in the grou
-
Burning VIDEO_TS to DVD
Hello all, I have a VIDEO_TS folder from a DVD. Legal, of course...well, anyway, I'd like to burn it to a new blank DVD to make a disc compatible with any DVD player, not just a Mac/Windows computer. I actually tried it with Disco (www.discoapp.com)
-
Nano wont update, wont play video
I just bought my two little sisters both ipod nano's and when i try to add video it wont go on the ipod, and it keeps telling me to update the ipod software but when i do, it downloads and freezes and says intunes network is unavailable. I've tried t
-
1) I have a table full of data 2) I have an XML schema 3) I need to get the data from the table and put it into an XML file that conforms to the XML schema. 4) I don't want to write a ton of PL/SQL to manually output the XML. There are so many produc
-
Can not use Silverfast scanning technology or my Epson 2100 Colour Stylus printer since upgrading to Mac OS X Lion. I had been assured that Silverfast would work and had no idea the printer would become redundent! Not Good information from Apple!! An