Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Include Structure (Twice)

Former Member
0 Likes
4,217

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..

14 REPLIES 14
Read only

KalC
Active Participant
0 Likes
2,945

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.

Read only

ThomasZloch
Active Contributor
0 Likes
2,945

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

Read only

Former Member
0 Likes
2,945

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)

Read only

0 Likes
2,945

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

Read only

0 Likes
2,945

Thanks Marcin for pointing this out, I have never used this and wasn't aware of it.

Thomas

Read only

0 Likes
2,945

@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

Read only

Former Member
0 Likes
2,945

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

Read only

Former Member
0 Likes
2,945

Thanks for reply Experts.

Thanks

Dharma

Read only

0 Likes
2,945

Hi Dharma,

If this solves your issue, please close the thread.

Regards

Marcin

Read only

0 Likes
2,945

Marcin - this isn't marked as a question, so it starts off "closed".

Rob

Read only

0 Likes
2,945

Thanks Rob, this time I wasn't aware of that

Regards

Marcin

Read only

0 Likes
2,945

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

Read only

0 Likes
2,945

Hehe thanks for your generosity

Read only

0 Likes
2,945

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