1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Dataset Read-xml Buffer 1 Is Empty

Discussion in 'Development' started by Jochen0911, Nov 12, 2017.

  1. Jochen0911

    Jochen0911 New Member

    Hello,
    tried to create dataset, write-xml and read it again. But it doesn´t work. Perhaps, it´s a simple thing, but i don´t see it.

    I have 2 TT. ttAuftrag and ttAufPos.

    ttAuftrag

    field lfdnr as int xml-node-type 'HIDDEN':U

    field firma like v_belegkopf.firma xml-node-type 'HIDDEN':U
    field kunde like v_belegkopf.kunde xml-node-type 'ATTRIBUTE':U xml-node-name 'Kundennummer':U
    field web_bestellnr as char format 'x(30)':U xml-node-name 'WEB_Bestellnummer':U
    field bestellreferenz as char format 'x(30)':U xml-node-name 'Bestellreferenz':U
    field auftragsart like v_belegkopf.auftragsart xml-node-name 'Auftragsart':U
    field lieferadresse as char xml-node-name 'Lieferadresse':U
    field rechnungsadresse as char xml-node-name 'Rechnungsadresse':U
    field empfaenger like v_belegkopf.empfaenger xml-node-name 'Empfänger':U
    field frachtkosten as dec format 'zzz,zz9.99-':U xml-node-name 'Frachtkosten':U
    field bemerkung as char format 'x(60)':U xml-node-name 'Bemerkung':U
    field payment1 as char format 'x(124)':U xml-node-name 'Payment1':U
    field payment2 as char format 'x(124)':U xml-node-name 'Payment2':U
    field payment3 as char format 'x(124)':U xml-node-name 'Payment3':U
    field payment4 as char format 'x(124)':U xml-node-name 'Payment4':U
    field belegnummer like v_belegkopf.belegnummer xml-node-name 'PA_Belegnummer':U


    ttAufPos
    field lfdnr as int xml-node-type 'HIDDEN':U

    field firma like v_belegkopf.firma xml-node-type 'HIDDEN':U
    field web_bestellnr as char format 'x(30)':U xml-node-name 'WEB_Bestellnummer':U
    field positionsnr as char format 'x(20)':U xml-node-name 'Positionsnummer':U
    field artikel like v_belegpos.artikel xml-node-name 'Teilenummer':U
    field menge like v_belegpos.menge xml-node-name 'Menge':U
    field preis like v_belegpos.einzelpreis xml-node-name 'Preis':U

    Dataset
    define dataset {&ppDatasetName}

    xml-node-name 'AUFTRAG':U

    for ttAuftrag{&ippPostfix},ttAufPos{&ippPostfix}

    data-relation drAuftrag
    for ttAuftrag{&ippPostfix},ttAufPos{&ippPostfix}
    relation-fields (web_bestellnr,web_bestellnr)
    nested.

    I created sample data, called fill-dataset and called write-xml. That works. Auftrag_Beispiel_20171112_15_19_38.zip

    Now i wanted to read XML to get Dataset info.

    lvh_ds = dataset dsauftrag:handle.

    lvl_ret = lvh_ds:read-xml('file':U,lvc_datei_akt,?,?,false) no-error.


    That works, but i have only the positions

    for each ttauftrag:
    message '1'.

    end.
    for each ttaufpos:
    message '1'.

    end.


    ttauftrag is empty. No message. ttaufpos i get my positions. So, what´s going wrong?
     

    Attached Files:

  2.  
  3. Stefan

    Stefan Active Member

    Could you just add one program (in code tags) that defines the dataset, creates some sample data writes it, reads it and illustrates the issue?
     
  4. Jochen0911

    Jochen0911 New Member

    define dataset

    Code (progress):
    1. define dataset {&ppDatasetName}
    2.  
    3.   xml-node-name 'AUFTRAG':U
    4.  
    5.   &IF "{&ippNoReferenceOnlySwitch}" <> "YES"
    6.   &THEN
    7.   reference-only
    8.   &ENDIF
    9.  
    10.   for ttAuftrag{&ippPostfix},ttAufPos{&ippPostfix}
    11.  
    12.   data-relation drAuftrag
    13.     for ttAuftrag{&ippPostfix},ttAufPos{&ippPostfix}
    14.     relation-fields (web_bestellnr,web_bestellnr)
    15.                     nested.

    fill dataset

    Code (progress):
    1. PROCEDURE fillDataset :
    2. /* Description ---------------------------------------------------------------*/
    3. /*                                                                            */
    4. /* Fuellt Dataset fuer den Export                                             */
    5. /*                                                                            */
    6. /*----------------------------------------------------------------------------*/
    7. def input-output parameter dataset for dsAuftrag.
    8.  
    9. def var lvc_meldung as char no-undo.
    10.  
    11. MAIN:
    12. do on error  undo MAIN, retry MAIN
    13.    on endkey undo MAIN, return error:
    14.  
    15.   if retry
    16.   then do:
    17.  
    18.  
    19.   end. /* RETRY */
    20.  
    21.   /* Beispielexport */
    22.   create ttAuftrag.
    23.   assign
    24.     ttAuftrag.firma            = '100'
    25.     ttAuftrag.kunde            = 100002
    26.     ttAuftrag.web_bestellnr    = 'abc123'
    27.     ttAuftrag.bestellreferenz  = '12345'
    28.     ttAuftrag.auftragsart      = ''
    29.     ttAuftrag.lieferadresse    = '1'
    30.     ttAuftrag.rechnungsadresse = '1'
    31.     ttAuftrag.empfaenger       = 'empfänger'
    32.     ttAuftrag.frachtkosten     = 12.50
    33.     ttAuftrag.bemerkung        = 'Bemerkung'
    34.     ttAuftrag.payment1         = 'Pay1'
    35.     ttAuftrag.payment2         = 'Pay2'
    36.     ttAuftrag.payment3         = 'Pay3'
    37.     ttAuftrag.payment4         = 'Pay4'.
    38.  
    39.   create ttAufPos.
    40.   assign
    41.     ttAufPos.firma           = '100'
    42.     ttAufPos.web_bestellnr = 'abc123'
    43.     ttAufPos.positionsnr     = '1'
    44.     ttAufPos.artikel         = '31105090-00'
    45.     ttAufPos.menge           = 10
    46.     ttAufPos.preis           = 412.50.
    47.  
    48.   create ttAufPos.
    49.   assign
    50.     ttAufPos.firma           = '100'
    51.     ttAufPos.web_bestellnr   = 'abc123'
    52.     ttAufPos.positionsnr     = '2'
    53.     ttAufPos.artikel         = '50000000-00'
    54.     ttAufPos.menge           = 1
    55.     ttAufPos.preis           = 2.55.
    56.  
    57. end. /* MAIN */
    58.  
    59. end procedure. /* fillDataset */
    60.  


    Write XML

    Code (progress):
    1. {y/gateway/incl/yg_auf00.pds
    2.   &ippNoReferenceOnlySwitch = yes
    3. }
    4. {y/gateway/incl/yg_auf00.pds
    5.   &ippNoReferenceOnlySwitch = yes
    6.   &ippPostfix               = _rc
    7. }
    8.  
    9.  
    10.  
    11. Main:
    12. do
    13. on error  undo Main, retry
    14. on endkey undo Main, leave:
    15.  
    16. if retry
    17. then do:
    18.   message 'fehler'.
    19.   leave.
    20. end.
    21.  
    22.  
    23.  {call dsAuftrag emptyDataset}.
    24.  
    25.   {call dsAuftrag fillDataset} .
    26.  
    27.  
    28.   dataset dsAuftrag:write-xml('file':U,
    29.                               'd:\temp'
    30.                                 + {&pa-backslash}
    31.                                 + 'Auftrag_Beispiel_':U
    32.                                 + string(year(today),'9999':U)
    33.                                 + string(month(today),'99':U)
    34.                                 + string(day(today),'99':U)
    35.                                 + '_':U
    36.                                 + replace(string(time,'hh:mm:ss':U),':':U,'_':U)
    37.                                 + '.xml':U,
    38.                               yes,
    39.                               'UTF-8':U,
    40.                               '':U,
    41.                               yes).
    42.  
    43. end. /* Main */


    READ XML
    Code (progress):
    1. {y/gateway/incl/yg_auf00.pds
    2.   &ippNoReferenceOnlySwitch = yes
    3. }
    4. {y/gateway/incl/yg_auf00.pds
    5.   &ippNoReferenceOnlySwitch = yes
    6.   &ippPostfix               = _rc
    7. }
    8.  
    9.  
    10. Main:
    11. do
    12. on error  undo Main, retry
    13. on endkey undo Main, leave:
    14.  
    15. if retry
    16. then do:
    17.   message 'fehler'.
    18.   leave.
    19. end.
    20.  
    21. gvc_vz = 'd:\temp\Auftrag_Beispiel_20171113_06_28_49.xml'.
    22.  
    23. gvh_ds = dataset dsauftrag:handle.
    24.  
    25.   gvl_ret = gvh_ds:read-xml('file':U,gvc_vz,?,?,false) no-error.
    26.  
    27.  
    28.  
    29.   if error-status:error
    30.     or gvl_ret = false
    31.   then do:
    32.  
    33.     do gvi_zaehler = 1 to error-status:num-messages:
    34.         message error-status:get-number(gvi_zaehler)) error-status:get-message(gvi_zaehler).
    35.  
    36.     end. /* do lvi_zaehler = 1 to error-status:num-messages: */
    37.  
    38.   end. /* if error-status:error */
    39.  
    40.  
    41.  
    42. for each ttauftrag:
    43.   /* THIS message don´t appears */
    44.   message '1 auftrag'.
    45.  
    46. end.
    47. for each ttaufpos:
    48.   message '2 pos'.
    49.  
    50. end.

    for each ttauftrag doesn´t appear. I seems like Read-XML have a problem with the top buffer?
     
  5. Stefan

    Stefan Active Member

    That's not a one .p example but incomplete bits and pieces.

    ABL Dojo

    Is a reconstruction of what you are providing and it works fine.
     
    Cecil likes this.
  6. Jochen0911

    Jochen0911 New Member

    Thank you for your hints! ABL Dojo works also fine for me. So i searched further form my problem. I´am working in a framework. When i rename the XML-Node 'Auftrag' to 'ttAuftrag', it worked and the error is solved.
     

Share This Page