‎2009 May 27 8:41 AM
hi Exports!
I am using more than one zstructure in a table (include structure),but it is not accept the same Structure . It showing the error like the field twicely used.
Is it possible to acees more than on stru in a table ? Any alternate way?
Thanks all...
Dharma..
‎2009 May 27 8:57 AM
Hi,
Either create new structure with different fieldnames but with same data elements or add new fields to the same structure with different fieldnames and same data elements.
Thanks & Regards,
Kalyan.
‎2009 May 27 9:01 AM
Of course you can include more than one structure in one table, and of course you cannot include the same structure twice due to the duplicate field names, as you found out.
Why on earth would you want to include the same structure twice?
Thomas
‎2009 May 27 9:37 AM
Thanks for reply Guys
Kalyan
Thomas Zloch
Finally I understand, we can't use more than one stru in a table.
(My senario : I have create zdr_str_address for Present address and also include this structure for permanent address)
‎2009 May 27 10:16 AM
you cannot include the same structure twice due to the duplicate field names, as you found out.
I must disagree here.
Although there can't be the same field name used more than once, you can include same structure any times you wish, by means of SUFFIXes
- in SE11 edit your target table (or structure)
- from menu bar choose Edit->Include->Insert
- type in Structure name zdr_str_address
- in Group (optionally) i.e type present_address , this way you can address entire substructure with using ztable-present_address in your program
- in Name Suffix use i.e _PS - which would stand for present
- repeat that process to include structure second time bu in as Group use permanent_address and as Suffix use _PR .
As a result you should be having two includes:
- .INCLU-_PS
- .INCLU-_PR
which hold same structure. Only difference is that components have this suffix used i.e
- street_ps - for include _PS
- street_pr - for include _PR
What is more in program you don't have to distinguish which you are currently addressing (unless you do this in some procedure). Look at this example
data: itab type table of ztable.
...
perform get_address itab-present_address. "pass entire structure
peroform get_address itab-permanent_address. "pass entire second structure
form get_address using fs_address type zdr_str_address.
"here static structure type zdr_str_address is used, not dynamic one
"so you can access components of both strcuture without suffixes
fs_address-street. "in first perform you address in fact street_ps, in second street_pr
endform.
"but outside the form, you have to use suffixes
itab-street_ps = ....
endform.
Typing is really powerfull in ABAP, just make use of it:)
Regards
Marcin
‎2009 May 27 12:41 PM
Thanks Marcin for pointing this out, I have never used this and wasn't aware of it.
Thomas
‎2009 May 27 1:04 PM
@Thomas
Though I have great respect to your technical expertise here in SCN, this just proves that we are learning all the time
@Siddarth
We already agreed that this is feasible.
Cheers
Marcin
‎2009 May 27 12:50 PM
hi,
u can use more than one include structure in the table... but the include structures should not contain the same field name.... if it contains the same fieldname it will give you errors....
Regards,
Siddarth
‎2009 May 28 12:05 PM
‎2009 May 28 6:15 PM
Hi Dharma,
If this solves your issue, please close the thread.
Regards
Marcin
‎2009 May 28 6:27 PM
Marcin - this isn't marked as a question, so it starts off "closed".
Rob
‎2009 May 28 6:30 PM
‎2009 May 28 6:32 PM
And it's too bad it wasn't - yours was the best answer I've seen in a long time.
10 (virtual) points for you.
Rob
‎2009 May 28 6:53 PM
‎2009 Jun 09 10:21 AM
Hi,
I just wanted to refer this help link here,
http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ebc9446011d189700000e8322d00/frameset.htm
Thanks,
Manjula.S
Edited by: Rob Burbank on Jun 9, 2009 9:20 AM