Skip to Content
author's profile photo Former Member
Former Member

Java-Hierarchylevel - Error

Hallo,

i try to describe my problem in the english language:

I wrote the following code:

/***************************************************/

public IDoc.Document createOrderIdoc(SalesOrder order,IDoc.Document doc)

{

IDoc.Segment root, segment;

root = doc.getRootSegment();

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

// Ebene 1

segment = root.addChild("E1EDK01");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("ACTION", "000");

// Ebene 2

segment = segment.addChild("Z1KGSKOPF");

System.out.println( 2. Level: "+ segment.getHierarchyLevel());

segment.setField("ZZDKO", order.getOrderKostenstelle());

segment.setField("ZZRKAUFNR", order.getOrderAuftragsNr());

segment.setField("ZZTIT", "3000");

segment.setField("ZZAUF", kundennummer);

// Ebene 1: Vertriebsweg

System.out.println(0. Level: "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK14");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

// ERROR: Println: 1. Level

2

// ERROR: root.addChild puts this element in Level 2 and not in level 1.

segment.setField("QUALF","007");

segment.setField("ORGID","30");

// Ebene 1: Sparte

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK14");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("QUALF","006");

segment.setField("ORGID","01");

// Ebene 1: Verkaufsorganisation

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK14");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("QUALF","008");

segment.setField("ORGID","0001");

// Ebene 1: Auftragsart

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK14");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("QUALF","012");

segment.setField("ORGID","TG");

// Ebene 1: Partnerrolle Auftraggeber

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDKA1");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("PARVW","AG");

segment.setField("PARTN", kundennummer);

segment.setField("IHREZ", order.getOrderNr() + "/" + orderDate);

// Ebene 1: Partnerrolle Auftraggeber

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK02");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("QUALF","001");

segment.setField("BELNR", order.getUserFon());

// Ebene 1: Partnerrolle Warenempfänger

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDKA1");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("PARVW","WE");

segment.setField("PARTN", kundennummer);

segment.setField("NAME1", order.getDelCompany());

segment.setField("NAME2", order.getDelNiederlassung());

segment.setField("NAME3", order.getDelRessort());

segment.setField("NAME4", order.getDelSal() +

order.getDelFName() +

order.getDelLName());

segment.setField("STRAS", order.getDelStreet() +

order.getDelStreetnr());

segment.setField("ORT01", order.getDelCity());

segment.setField("PSTLZ", order.getDelZIP());

segment.setField("LAND1", order.getDelCountry());

// Ebene 1: Bestellnummer des Kunden

System.out.println(0. LEVEL "+ root.getHierarchyLevel());

segment = root.addChild("E1EDK02");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment.setField("QUALF","001");

segment.setField("BELNR",order.getOrderNr());

// process all order items of this order

posNr = 10;

itItems = order.getOrderItems().iterator();

while (itItems.hasNext()) {

item = (OrderItem) itItems.next();

// Ebene 1: Bestellte Artikel

System.out.println(0. Level "+ root.getHierarchyLevel());

}

segment = root.addChild("E1EDP01");

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

}

segment.setField("POSEX", String.valueOf(posNr));

segment.setField("MATNR", item.getArtNum());

segment.setField("MENGE", item.getArtAmount());

segment.setField("MENEE", getIsoCode(item.getArtVE()));

posNr += 10;

}//while

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

// Ebene 2

System.out.println( 1. LEVEL "+ segment.getHierarchyLevel());

segment = segment.addChild("Z1KGSPOS");

System.out.println( 2. LEVEL "+ segment.getHierarchyLevel());

segment.setField("ZZDKO", order.getOrderKostenstelle());

segment.setField("ZZRKAUFNR", order.getOrderAuftragsNr());

segment.setField("ZZOZT", order.getOrderOrdnungszahl());

//prepare document for sending and set the appropriate control data

doc.checkSyntax();

}

/***************************************************/

Now my big problem. At the line doc.checkSyntax throws the Java-program the following error:

/***************************************************/

com.sap.mw.idoc.IDoc$SyntaxException: (1) IDOC_ERROR_SYNTAX: Missing mandatory segment: Z1KGSPOS

at com.sap.mw.idoc.jco.JCoIDoc$JCoSegment.checkMandatoryChildSegments(JCoIDoc.java:6395)

at com.sap.mw.idoc.jco.JCoIDoc$JCoSegment.checkSyntax(JCoIDoc.java:6440)

at com.sap.mw.idoc.jco.JCoIDoc$JCoSegment.checkSyntax(JCoIDoc.java:6450)

at com.sap.mw.idoc.jco.JCoIDoc$JCoDocument.checkSyntax(JCoIDoc.java:933)

at com.sap.mw.idoc.jco.JCoIDoc$JCoDocument.checkSyntax(JCoIDoc.java:887)

at connector.ConnectorSap.createOrderIdoc(ConnectorSap.java:318)

at connector.ConnectorSap.createOrderIDocList(ConnectorSap.java:355)

at connector.ConnectorSap.sendSapOrders(ConnectorSap.java:387)

at connector.SapOrderManager.sendSapOrders(SapOrderManager.java:46)

at connector.SapOrderManager.main(SapOrderManager.java:55)

/***************************************************/

I think the reason is, that the segment "Z1KGSPOS" lies in the wrong HierarchyLevel. In the Metadata which i get from the Sap-Server, it has to be set in Level 2. But my Java-programm puts it always in Level 3.

I think the problem accrues at the marked position in top java code. But i don´t understand whats the reason for!!!

Why did the function root.addChild(...) put the segment in Level 2 and not as desired in Level 1.

I hope anyone of you could help me!!!

Thanks from Germany

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2004 at 01:31 PM

    Hi Stefan,

    I'm not sure I understand your problem; since I have no clue about your IDoc definition, my answer is based on ORDERS05, which might not be appropriate in your case.

    Segment E1EDK14 is level 2 and not level 1; check out the definition of your IDoc. From your coding I see, that you add your custom segment Z1KGSPOS after E1EDP01. E1EDP02 is on level 2, so your segment should end up on level 3. So far so good.

    Where did you place your Z1KGSPOS segment? Natural choice would be below the E1EDP01 segment, as standard SAP defines all other item segments that way. If you did that then the syntax error is caused by first adding all E1EDP01 segments and then adding the Z1KGSPOS. I guess you might've just misplaced your closing brace for your while loop.

    Hope this helps, harald

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.