Nested structures within ABAP
Hello,
I am working on an ABAP report where the output file will need to look something like:-
1 Material No, Description
2 EAN, ...
3 ..., ..., ...
3 ..., ..., ...
4 ..., ..., ...
4 ..., ...
Some of the record types will only have one line and others will have multiple.
I was hoping to create an internal table into which I could extract all of the relevant data.
To do this, I was thinking of setting up my internal table as a nested structure so I would define some types for each record type
e.g.
types: begin of rec_type_1
matnr like mara-matnr
end of rec_type_1
types: begin of rec_type_2
end of rec_type_2
and then I could declare my internal table something like:-
data: begin of itab
rec1 type rec_type_1
rec2 type rec_type_2
end of itab
I could then extract the relevant information for each material into the appropriate record types.
This will work OK for all the record types where this is only going to be 1 line per material but I am not sure how to extend this for the record structures for which there will be multiple lines per material.
I was thinking of declaring a table and then adding this as an element into the itan structure.
Will this work? And does anyone have any code samples of this sort of thing?
Thanks,
Ruby
Hi
I think so but it should be better you structure was:
types: begin of rec_type_1
end of rec_type_1.
types: begin of rec_type_2
end of rec_type_2.
types: t_rec_type1 type standard table of rec_type_1,
t_rec_type2 type standard table of rec_type_2.
data: begin of itab occurs 0,
matnr type matnr,
rec1 type t_rec_type_1
rec2 type t_rec_type_2
end of itab.
data: wa1 type rec_type_1,
wa2 type rec_type_2.
SORT ITAB BY MATNR.
LOOP AT ITAB.
WRITE ITAB-MATNR.
SORT ITAB-REC1 BY ...
LOOP AT ITAB-REC1 INTO WA1.
WRITE WA1.
ENDLOOP.
SORT ITAB-REC2 BY ...
LOOP AT ITAB-REC2 INTO WA2.
WRITE WA2.
ENDLOOP.
ENDLOOP.
Max
Similar Messages
-
Data Type structure within ABAP
Can the structure of a message type within XI be seen using ABAP.
Hi Martin !
I'm afraid not. The process works the other way around. You can create/define it in ABAP and then import it in XI (as RFC).
Or design it in XI (Integration Repository) and "export" it as an ABAP Proxy class in SAP ERP.
Regards,
Matias. -
I would like to know how to use nested structure in a ABAP program.
Thanks in Advance!A <b>nested structure</b> is a structure that contains one or more other structures as components.
Flat structures contain only elementary data types with a fixed length
(no internal tables, reference types, or strings).
The term deep structure can apply regardless of whether the structure is nested or not.
Nested structures are flat so long as none of the above types is contained in any nesting level.
Any structure that contains at least one internal table, reference type, or string as a component
(regardless of nesting) is a deep structure.
Accordingly, internal tables, references, and strings are also known as deep data types.
The technical difference between deep structures and all others is as follows:
When you create a deep structure, the system creates a pointer in memory that points to the
real field contents or other administrative information.
When you create a flat data type, the actual field contents are stored with the type in memory.
Since the field contents are not stored with the field descriptions in the case of deep structures,
assignments, offset and length specifications and other operations are handled differently from flat structures.
Kindly check the following link for more information on Nested structures:
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/frameset.htm
<b>Examples:</b>
DATA: BEGIN OF itab.
include structure vbak.
DATA: END OF itab.
DATA: BEGIN OF itab OCCURS 0,
itab1 LIKE mara,
itab2 LIKE vbak,
END OF itab.
Kindly reward points if it helps!
best regards,
Thangesh -
How to convert sequencial textlines into nested structure?
Hi experts,
I have an input-TXT file in which I get headerdata (1 line), positiondata (n lines) and for each position partnerdata (n lines). I have to map this data to Idoc ORDERS05. In this structure, there is 1 element per position (E1EDP01) which contains a subelement where I can enter position-partners. How can I achieve this mapping using the graphical message mapping tool in XI?
Example lines of inputfile:
(headerdata) 199992;100;10;...
(positiondata) 10;100200;50
(positionpartners) 10;partner1
(positionpartners) 10;partner2
(positionpartners) 10;partner3
(positionpartners) 10;partner4
(positiondata) 20;100201;100
(positionpartners) 20;partner1
(positionpartners) 20;partner2
(positiondata) 30;100202;75
must result in:
headerdata linked to E1EDK01, no problem
positiondata linked to E1EDP01, no problem
positionpartners linked to E1EDPA1 within E1EDP01. Here is the problem...just linking the input-positionpartners to EDEDPA1 does not work. Then I get all positionpartners of the complete inputfile linked to the first E1EDP01, and no partners from the second E1EDP01 on...
Regards,
WilliamHey,
First step is create a mapping structure(i.e data type and message type) which will be convenient
for you to map with the Idoc.
Then you can use File content conversion to convert the text file into the nested structure(one which you have created))
/people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter
refer to this blog in order to convert the input file stream into the required nested structure.
Once done this map the message type to your Idoc.
revert in case of any problem with FCC(file content conversion).
reward points if useful. -
Fill internal table with mutliple entries for nested structure
Dear ABAP Experts,
I have a question related to fill internal tables with nested structures.
I have a structure like this:
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
BEGIN OF kons,
kon TYPE YKONSEINHEIT,
END OF kons,
jahr TYPE CHAR04,
END OF proto.
Now I need to fill this structure with values (over an internal table), but how can I achieve that I save multiple datas für element "kon" für one single entry of structure "proto"?
An example could be:
sicht = '01'
version = '100'
kon = 1001 (first entry)
kon = 1002 (second entry)
usw... (n entry)
jahr = '2008'
Thanks in advance for every helpful answer.
Regards
ThomasBEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
jahr TYPE CHAR04,
END OF proto.
DATA: ls_proto TYPE proto,
lt_proto TYPE STANDARD TABLE OF proto,
ls_kon
ls_proto-sicht = '01'.
ls_proto-version = '100'
INSERT '1001' INTO TABLE ls_proto-kons.
INSERT '1002' INTO TABLE ls_proto-kons.
ls_proto-jahr = '2008'.
INSERT ls_proto INTO TABLE lt_proto
If you're going to use a more complicated inner table with several components, then you need to define a type for those components.
matt -
Wht r types of structures in ABAP
Hi,
Wht r types of structures in ABAP. Answer rewarded.
Regds.
Balakri...Hi baddala,
Structures which either directly or in substructures contain only fields of types C, N, D or T.
The main characteristics of the different kinds of structures are:
Flat structures contain only fields of the elementary types C, N, D, T, F, I, P, and X, or structures containing these types.
Deep structures contain strings, internal tables and field or object references in addition to the elementary types.
Nested structures are structures that contain substructures as components.
Non-nested structures are structures that do not contain any substructures.
\[removed by moderator\]
Edited by: Jan Stallkamp on Jun 10, 2008 2:24 PM -
Nesting Roles within Roles, is it used in practice ?
Can the Oracle DBA community comment of the practice of nesting one or more roles within another role. Said another way, the concept of creating "super-group" role and assigning "sub-group" roles beneath them.
1. Is this concidered to be good or bad practice ?
2. Would you consider this easy to maintain, and report on, would you concider this be effective for security and administration of security policies ?
3. Are there known issues (technical, performance, security, bugs, other) when nesting roles within another "super-group" role for Oracle 8i, 9i, 10g ?I would certainly consider it good practice if your organization is structured such that the role heirarchy makes sense. If your organizational structure doesn't support this kind of hierarchy, though, it is probably a bad idea.
If you have just a few types of users for your system-- a couple of developers, some reporting users, and a DBA or two-- having three distinct roles makes more sense to me than would giving developers the reporting user role plus access to a bunch of stored procedures. If you have more fine-grained job roles, however, it would make sense to nest roles-- a senior developer role might have the developer role plus some additional privileges to enable tracing or to do some "Jr DBA" tasks like creating a new reporting user.
It seems easiest to me to match your privilege management to your organization and application structure-- if there are roles whose function is logically "all the responsibilities of another role plus some additional responsibilities", nest your roles. Otherwise, I would keep them separate. If you start nesting things too deeply, and you start getting down to object-level permissions, I would consider moving to something like fine-grained access control (FGAC).
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Nested structure when using FM XXL_SIMPLE_API
I use this logic to fill in the headings before calling the FM xxl_simple_api in one of my programs. Is it possible to have nested structure(for <b>i_tab</b> in my code) and still use same kind of logic to fill in the headings? Not sure if this Fm would display data correctly when there is a component of strucutre type. I tried it, the field was blank with no contents in excel.
DATA : nlines TYPE i,
tempfile LIKE gxxlt_f-file,
descr_ref TYPE REF TO cl_abap_structdescr,
header LIKE gxxlt_v OCCURS 0 WITH HEADER LINE,
it_print LIKE gxxlt_p OCCURS 0 WITH HEADER LINE.
*data: keycol type i.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr,
tempfile = file_name.
REFRESH header.
CLEAR header.
descr_ref ?= cl_abap_typedescr=>describe_by_data( i_tab ).
DESCRIBE TABLE descr_ref->components LINES nlines.
nlines = nlines + 1.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
IF sy-tabix = nlines.
EXIT.
ELSE.
header-col_no = sy-tabix.
header-col_name = <comp_wa>-name.
APPEND header.
ENDIF.
ENDLOOP.
CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
filename = tempfile
N_KEY_COLS = keycol
TABLES
col_text = header[]
I appreciate your help. ThanksHi,
It's better to use another FM 'SAP_CONVERT_TO_XLS_FORMAT'
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
I_FIELD_SEPERATOR = seper
I_LINE_HEADER = 'X'
I_FILENAME = P_FILE
tables
I_TAB_SAP_DATA = itab
exceptions
CONVERSION_FAILED = 1.
Svetlin -
Is it possible to create a menu structure within iWeb with a so called tree layout? iWeb only provides automatically a horizontal layout
Not in iWeb itself.
You have to create these menus yourself. Start here :
A List Apart: Articles: Suckerfish Dropdowns
Also, see podcast episode 9 of
CSS Tricks and Tips
and then add them to a webpage with the HTML Snippet.
Or add the menu to the webpage with a JavaScript.
Here's a sample page :
http://www.wyodor.net/mfi/roodhout/
http://www.wyodor.net/mfi/spelling/
http://www.wyodor.net/mfi/Maaskant/Some_Menus.html
The how-to-do page are here and here.
More sample pages on my Made for iPad with iWeb pages.
http://www.wyodor.net/mfi/
You may have to learn HTML, CSS, JavaScript, AJAX, DOM and how iWeb creates its pages. -
File sender adapter: Content conversion for very deep nested structure
Hi all
I have a file which looks like this
HDOCKET 9800000660980000061911062009AA123456bbWM100012349800000619
DDOCKET_TEST001 4012YAG1
WZOA00000000010000000001
WZOA00000000020000000002
WZOB00000000030000000003
IAAXX000001
IAAXX000002
C0000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004
T2
and my structure is
Header - 1
Detail - 0....Unbounded
Bag - 0.....Unbounded (sub node of detail)
Track - 0.....Unbounded (sub node of detail)
Customer - 0.....Unbounded (sub node of detail)
Trailer - 1
and in the file sender adapter i mentioned the following content conversion setting
HEADER,1,DETAIL,*,Bag,*,Track,*,Customer,*,TRAILER,*
But when i go and see in the monitoring i received the following conversion
<?xml version="1.0" encoding="utf-8" ?>
<ns:MT_REQ xmlns:ns="http://royalmail.com/dd_c">
<HEADER>
<ID>H</ID>
<INT>DD</INT>
<CAR>9899999660</CAR>
<CUS>9899999619</CUS>
<POST>11062009</POST>
<NUMBER>AA123456bbWM10001234</NUMBER>
<ACC>9899999619</ACC>
</HEADER>
<DETAIL>
<ID>D</ID>
<Bag>DOCKET_TEST001</Bag>
<S>4012</S>
<Code>YAG</Code>
<mat>1</mat>
<count/>
<Mixed />
</DETAIL>
<Bag>
<ID>W</ID>
<Zone>ZOA</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>ZOA</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>ZOA</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
</Bag>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Track>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Tracked>
<Customer>
<ID>C</ID>
<OrigCustomer>00000000000000000001</OrigCustomer>
<Field1>00000000000000000001</Field1>
<Field2>00000000000000000002</Field2>
<Field3>00000000000000000003</Field3>
<Field4>00000000000000000004</Field4>
</Customer>
<TRAILER>
<ID>T</ID>
<Count>2</Count>
</TRAILER>
</ns:MT_REQ>
whereas i wanted it like:
<?xml version="1.0" encoding="utf-8" ?>
<ns:MT_REQ xmlns:ns="http://royalmail.com/dd_c">
<HEADER>
<ID>H</ID>
<INT>DD</INT>
<CAR>9899999660</CAR>
<CUS>9899999619</CUS>
<POST>11062009</POST>
<NUMBER>AA123456bbWM10001234</NUMBER>
<ACC>9899999619</ACC>
</HEADER>
<DETAIL>
<ID>D</ID>
<Bag>DD_TEST001</Bag>
<S>4012</S>
<Code>egg</Code>
<mat>1</mat>
<count/>
<Mixed />
<Bag>
<ID>W</ID>
<Zone>zzz</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>zzz</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>zzz</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
</Bag>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Track>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Tracked>
<Customer>
<ID>C</ID>
<OrigCustomer>00000000000000000001</OrigCustomer>
<Field1>00000000000000000001</Field1>
<Field2>00000000000000000002</Field2>
<Field3>00000000000000000003</Field3>
<Field4>00000000000000000004</Field4>
</Customer>
</DETAIL>
<DETAIL>
<ID>D</ID>
<Bag>DD_TEST002</Bag>
<S>4012</S>
<Code>egg</Code>
<mat>1</mat>
<count/>
<Mixed />
<Bag>
<ID>W</ID>
<Zone>zzzzzz</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>ZOA</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
<Bag>
<ID>W</ID>
<Zone>zzz</Zone>
<Item>0000000001</Item>
<Number>0000000001</Number>
</Bag>
</Bag>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Track>
<Track>
<ID>I</ID>
<Item>AAXX000001</Item>
</Tracked>
<Customer>
<ID>C</ID>
<OrigCustomer>00000000000000000001</OrigCustomer>
<Field1>00000000000000000001</Field1>
<Field2>00000000000000000002</Field2>
<Field3>00000000000000000003</Field3>
<Field4>00000000000000000004</Field4>
</Customer>
</DETAIL>
<TRAILER>
<ID>T</ID>
<Count>2</Count>
</TRAILER>
</ns:MT_REQ>
i.e. i need all Bag ,Track and Customer inside detail tag.
could anyone help me in this..i've already searched SDN and got some link as useful but none of them were totally related.
Regards
NainaNaina
Pls. check my forum link, i had the single level hierarchy XML file which I converted into nested structure & then into flat file.
File Conversion in Rec File Adapter with subnodes
This can give you an idea how to go ahead. Let me know in case you need any more info about this. -
Using nested Joins in abap prog
Hi All,
please help me out in using nested joins in abap progrmaming. I dont know about joins in abap.specially in case of outer join.
I have 5 internal tables.. mara ,marc, mvke,mbew,ampl. am using a select query with certain fields from all these tables.
I need to disply all the materials of a mara for a particular date irrespective of the values in fields of other tables.
Even if that materail is not present in other table for certain condtion ,that material should get displyed with all other fields showing null value..Hi RK,
the code am using is of the same way...but my problem was with the joins..in the select query am using nested join combining inner and outer join.. but i could not able to display all the materials of mara of a particular date..
The code looks like this..
SELECT <some fields.......>
INTO TABLE i_materials
FROM ( marc AS b
INNER JOIN mara AS a ON amatnr = bmatnr
INNER JOIN mvke AS c ON cmatnr = amatnr
INNER JOIN ampl AS g ON gbmatn = amatnr
LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
AND dbwkey = bwerks )
WHERE a~matnr IN s_matnr AND .................
Else
SELECT <some fields.......>
INTO TABLE i_materials
FROM ( marc AS b
INNER JOIN mara AS a ON amatnr = bmatnr
INNER JOIN mvke AS c ON cmatnr = amatnr
INNER JOIN ampl AS g ON gbmatn = amatnr
LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
AND dbwkey = bwerks )
FOR ALL ENTRIES IN i_mara
WHERE a~matnr = i_mara-matnr AND ............ -
Nested Structure handling in XML2Plain module of receiver SFTP aadaptor
Dear Experts,
Greeting for the day...
I am working on Receiver SFTP Adaptor scenario where I have to generate CSV file at receiver end. I am using XML2Plain module for the same. But I have a nested structure at receiver end. Receiver structure is given below.
General Header
Packet1
Node1
Field1, Field2...
Node2
Field1, Field2..
Node3
Field1, Field2..
Node4
Field1, Field2..
Packet2
Node1
Field1, Field2...
Node2
Field1,Field2...
Node3
Field1, Field2...
Node4
Field1, Field2..
File structure is as given below
General Header
Node1-field1,Field2..
Node2-Field1,Field2..
Node3-field1,Field2..
Node4-Field1,Field2..
Node1-field1,Field2..
Node2-Field1,Field2..
Node3-field1,Field2..
Node4-Field1,Field2..
I tried regular XML2Plain configuration but it is giving error "Message processing failed in XML parser: 'Conversion configuration error: Unknown structure 'Node1'".
Kindly suggest..
Thanks in advance.
Vinit.hi Vinit,
You can add another message mapping next to the original one such that Node1 can be treated as a field in new target and concat fields of Node1 with comma.
this way u can bring down the levels.
and finally the output mapping will look something like this
[General Header]
[Node1-field1,Field2..] [Node2-Field1,Field2..] [Node3-field1,Field2..] [Node4-Field1,Field2.]
[Node1-field1,Field2..] [Node2-Field1,Field2..] [Node3-field1,Field2..] [Node4-Field1,Field2.]
[Node1-field1,Field2..] [Node2-Field1,Field2..] [Node3-field1,Field2..] [Node4-Field1,Field2.]
[Node1-field1,Field2..] [Node2-Field1,Field2..] [Node3-field1,Field2..] [Node4-Field1,Field2.]
then in the channel u can give
field separator for the node fields as 'nl' which will bring your output as below.
General Header
Node1-field1,Field2..
Node2-Field1,Field2..
Node3-field1,Field2..
Node4-Field1,Field2..
Node1-field1,Field2..
Node2-Field1,Field2..
Node3-field1,Field2..
Node4-Field1,Field2..
hope this helps
thanks and regards,
Praveen T -
XML to internal table conversion within ABAP mapping class
I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
Thanks, DehraDehra,
Have you seen this weblogs which talks about this:
/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
/people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
/people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
Hope this helps you....
---Satish -
Regarding structure of abap program
hi,
can any one exaplain to me what is the structure of the abap program.
thank®ards,
ramnareshHi..
This is the Structure of ABAP program.
REPORT <NAME>.
**Global Data definitions
TYPES:
DATA:
**Selection Screen Definition
SELECT-OPTIONS
PARAMETERS
**Event Blocks
INITIALIZATION .
perform X.
START-OF-SELECTION.
perform Y.
****Form routines definition
FORM X.
ENDFORM.
FORM Y.
ENDFORM.
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo -
hi SDNs,
what is the typical structure of an ABAP program?
thanks and regards,
aravind.hi
plz check the structure of ABAP Program under..
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
below the typical structure...
1.data declaration
2.selection-screen declartion
3.data validation
4.output.
Cheers
Abdul Hakim
Maybe you are looking for
-
How to record a USB mic and a guitar at the same time?
I have an Audio-Technia AT-2020 USB mic and an Ovation acoustic/electric guitar. I wanted to record both of them at the same time, so i plugged the mic into the USB port (duh!) and the guitar into the 1/8" port on the computer (with a 1/4" to 1/8" ad
-
How to map one element to multiple target nodes? Kindly help!
Hi Experts, I have a source XML: <Inventory> <MaterialNo>Z001</MaterialNo> <InventoryLineItem> <BatchNo>B001</BatchNo> <Quantity>100</Quantity> </InventoryLineItem> <InventoryLineItem>
-
I'm having trouble with a Text Field and a Time Format
I have created a form. There are many text fields for clients to fill out. One Field have been formatted to enter a time. Ex. 6:00pm. This works great unless it's a 12:00am time then the field reads 00:00am I would rather it read 12:00 am. How can I
-
EXC_BAD_ACCESS from ExtAudioFileWriteAsync
I am using audio unit to record our voice. In my callback function I am getting data in AudioBufferList. I have to store this buffer in a file. Issue is; When I try to store the buffer in a .caf file, the application is crashing. Below is the code. <
-
Retrieving Parental Control Settings from Time Machine Backup
After having 20+ websites saved for "Allow access to only these websites" in Parental Controls I was experimenting and clicked on "unrestricted access" which caused all the websites we had saved to disappear when I decided to go back to "Allow access