Nested structure in a BAPI
Hi,
I have a requirement to create a bapi which can hold data in a nested format and output in the same format. Please could you help with any suggestions, or sample code to implement the same.
Thanks in advance
This is quite a basic question and this forum is not to place to ask it. But I can (and will) give you an example of a Standard SAP BAPI for retrieving business partner data which is nested.
Function Module (SE37):
BUPA_OUTBOUND_GET_MAIN
Similar Messages
-
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 -
How to add error message to return structure of calling BAPI from a BADI
i have a bapi where a badi is triggered.this badi method has just importing and changing parameters.is there any way with which i can add error message to the return structure of calling bapi.please reply at the earliest.High points can be expected.
thanks got it
-
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. -
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 -
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 -
Message Mapping Nested Structure to key node in JDBC XML SQL Structure
Hello everybody,
I'm facing the next problem, I have the following nested structure
<ns0:MT_Irdoc_ArchivoNested xmlns:ns0="http://ref.pemex.com/PI/FI/ArchivoIrdoc">
<Header id_consecutivo="">
<Transaction/>
<Header2/>
<Header3/>
<Header4/>
<Header5/>
<Detail>
<Transaction/>
<Detail2/>
<Detail3/>
<Detail4/>
<Detail5/>
</Detail>
</Header>
<NombreArchivo/>
</ns0:MT_Irdoc_ArchivoNested>
as you can see, Detail is a nested Node from Header Node, and Detail is with occurrence 0...unbounded, I need to generate a SELECT XML SQL Structure as follows
<StatementName>
<dbTableName action=u201DSELECTu201D>
<table>realDbTableName</table>
<access>
<col1/>
<col2/>
<col3/>
</access>
<key1>
<col4>val4</col4>
<col5>val5</col5>
<col6>val6</col6>
</key1>
</dbTableName>
</StatementName>
now my problem is that col4 and col6 are values mapped from Header fields values, and col5 mus be mapped from Detail2 field of Detail Nested Structure, and Detail is 0...unbounded so it can contain any number of values and must included in the key structure, I tried by mapping the Detail Node to the key1 node, so it will generate n numbers of key1 nodes to include in the query, and the Detail number of nodes are not constant so I can't generate key2, key3, keyn...., so what I need is to create n numbers of instances of key1 node, but the problem is that when the mapping try to generate the second instance of key1 node it gives an error in the fields that comes from Header structure, maybe I'm trying to solve my problem wrong, could anyone give some advices or direction?, thanks in advance.
Regards,
Julio CesarJulio,
After placing the below logic in the mapping editor
Details2 > SplitByValue> col5
Right click on the Details2 node and choose Context. By Default you will see Details, because Details2 is the child of Details node. I want you to choose the Parent of Details node, I believe that would be HeaderID, am I right?
If you don't want to do that then,
Details2 ---> Remove Context > SplitByvalue> col5 will do the trick!
raj. -
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. -
Help!! - File to Idoc Mapping with Nested structure
Scenario:
I have an inbound file that has three nested records.
eg. A00, B00 and C00. C00 is nested structure of B00 and B00 nested structure of A00. All these structure can repeat N number of times in a file.
How do I map this to IDoc structure that have one segment each for the three structures in the file and nested in the same way.
Question: How is the parent child relationship established?
Suppose I have a file
A00 1234 Sam 29
B00 london LE3 XYZ
B00 US 123456
C00 2 XYZ
A00 5678 Joe 22
B00 US 23456
If I make a nested structure and then say in the file conversion properties that A00 go to segA and then B00 go to segB, but then when I come back to A00, how do I move the data to the A00?
Thanks in Advance
RgdsFrom what you have layed out, you can create a data type with 3 children, all 1..unbounded cardinality, each containing their own elements. You say they are nested, but the example you gave isn't nested... it's just A's followed by B's followed by C's. If that is the case, you can then use a data type w/ 3 subelements (A, B & C) and each of those is actually a container with the real attributes of that line in your file. (I can email you a schema quickly if you need it)
If you are saying they can occur like this:
A00 1234 Sam 29
B00 london LE3 XYZ
B00 US 123456
C00 2 XYZ
B00 US 23456
C00 2 XYZ
THEN they are nested - ie B's & C's repeat under any A. Then you must create segment B as a subelement of segment A instead of on the same level, then bury C under B. (I find this easiest w/ a text tool rather than inside XI, as I can cut/paste segments where I want them to belong...)
Good luck with setting up content conversion on that file adapter... We have done this a few times, and it can be quite interesting.
If you have trouble with the schema, you can post your email & I can give you a quick example.
Message was edited by: Amanda Derringer -
How To fetch the Value of nested structure returned by RFC in c# application.
Hello ,
i am new to C#,i have rfc that return data from SAP system as Nested structure but when i fetching that data using
IrfcTable table = rfc.getTable("exporting_parameter"); // et_customer
it return's only first inner structure only .
for example my exporting internal table for rfc is
"et_customer" that contain sub structure as follow
gen_data
bank data
tax data
it return only value inside gen_data only.
how to get entire dataHi,
I am using Java JCO but I can see in the java doc that JCoTable have a Method
getTable
Check and see if you have it in .net
Regards. -
Receiver File content conversion with nested structure
Hi Guys,
I have the below nested structure and have to convert it using receiver file content conversion.
<Header> [o, unbounded]
<A>a</A>
<B>b</B>
</Header>
<record> [0, unbounded]
<field1>
<X1>x</X1>
<Y1>y</Y1>
</field1>
<field2>
<X2>x</X2>
<Y2>y</Y2>
</field2>
</record>
The file is a comma separated one. Please let me know how to configure the content conversion.
ThanksHi Mukesh,
Have a look at the Shabz's blog for the receiver File content conversion : File Adapter (Receiver) - Are we "really" sure about the concepts?
Thanks,
Pooja -
Select (join) into internal table with nested structures
Hello Experts,
i wonder about the correct notation of a select statement.
I have an internal table it_zoll including two structures as defined below.
The select is a join on the two tables zollp and zolls. As coded below the select is syntactically correct, but the fields
in the nested structures are not filled ....
Any ideas how to write the select statement ? (The internal table it_zoll must have the nested structures for other reasons ..)
Declaration:
TYPES: BEGIN OF ty_zollp,
belnr TYPE zollp-belnr,
werks TYPE zollp-werks,
gebnr TYPE zollp-gebnr,
END OF ty_zollp.
TYPES: BEGIN OF ty_zolls,
grnum type zolls-grnum,
werks type zolls-werks,
name1 TYPE zolls-name1,
END OF ty_zolls.
DATA: BEGIN OF wa_zoll.
DATA: zollp type ty_zollp.
DATA: zolls type ty_zolls.
DATA: END OF wa_zoll.
DATA: it_zoll LIKE TABLE OF wa_zoll.
Select:
SELECT
zollp~belnr zollp~werks zollp~gebnr
zolls~grnum zolls~werks zolls~name1
FROM zollp
JOIN zolls ON zolls~werks = zollp~werks
AND zolls~grnum = zollp~grnum
INTO CORRESPONDING FIELDS OF TABLE it_zoll
WHERE zollp~werks = werks
AND zollp~gebnr IN s-gebnr
AND ...
Thank you !DATA: BEGIN OF ty_zollp,
belnr TYPE zollp-belnr,
werks TYPE zollp-werks,
gebnr TYPE zollp-gebnr,
END OF ty_zollp.
DATA: BEGIN OF ty_zolls,
grnum type zolls-grnum,
werks type zolls-werks,
name1 TYPE zolls-name1,
END OF ty_zolls.
DATA: BEGIN OF wa_zoll.
Include structure ty_zollp.
Include structure ty_zolls.
DATA: END OF wa_zoll.
The above declaration had worked. Please try.
Regards,
Satish Kanteti -
Help regarding structure field for BAPI
Hi all,
I need to select print GR/GI slip and Collective slip in the initial screen of MB1A.
I am using bapi BAPI_GOODSMVT_CREATE.Can anyone tell the corresponding fields for the above things, so that i can pass to BAPI.
I looked at the structure related to bapi, but i could not figured it out.
Anyhelp would be greatly appeciated.
screen field RM07M-XNAPR -to pront gr/gi slip
RM07M-WVERS3-collective slip
i need to pass X to this fields and then bapi
Thanksuse these fields in the header
VER_GR_GI_SLIP
VER_GR_GI_SLIPX
also check this thread:
BAPI_GOODSMVT_CREATE: printing GR/GI slip -
BAdI - AC_DOCUMENT / data passing for nested structures
Hi all.
I need your help for this scenario:
I used this to pass value of MM field to FI field from transaction MIGO.
Our company placed field in EKKN-WEMPF to BSEG-ZUONR.
For this one option was: BAdI AC_DOCUMENT
Questions:
1. Nested structures - passing of data:
First problem encountered was with the reading of data from nested structures and passing them to nested structures as well. How to do this? I have used a certain declaration but any input will be much appreciated.
2. When I activated my BAdI, it says error on FI Interface,
specifically on AWREF and AWORG fields.
It is currently blank. Can I use the values in IM_DOCUMENT to pass to EX_DOCUMENT?
(What is a good way to do it since simple syntax does not allow for passing of data bec. structures are incompatible, and added complexity, it has nested structures.)
If you have sample code for this, it would truly be helpful.
Thanks and God bless!Hi,
Check that for which condition the message is triggering.
Try to check the condition.
Regards
Sandipan -
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
Maybe you are looking for
-
Getting a single value from an array collection
I have an array collection that was created from an XML file through the HTTP Service. One of the nodes in the XML file was product_number and I can display all of the items in this node in a datagrid so I know the array has the name of the node in i
-
Problems with Java, (i.e, compiling, etc) & Terminal Window
I am having a problem compiling my program in the Terminal Window. I am working on Java for my ICS class and the first project compiled and ran fine through Terminal Window, but when the next assignment came, it throws this error: class file has wron
-
Restoring data from old iphone
Hi! I had a 3g 16 gb iphone that was destroyed. My insurance payed for a new one, but when I connected it, itunes asked me if I wanted to merge the data stored from my old phone into it or if I wanted to treat it as a new one. I chose the merging opt
-
I am getting a pop-up that says the computer is not authorized and instructs me to go to Store>Authorize Computer, where in the store is the tab to authorize the computer?
-
Can't remove pictogram on bureauscre​en
The Lenovo burnsoftware stands on mine bureaupage and ik can't remove it It is a icoon of the burningprogramme of Lenovo with 4 kubes. I don't want them on mine bureauscreen. Can anyone tell how to do remove that.