• 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

#1
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?
 

Attachments

Stefan

Active Member
#2
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?
 
#3
define dataset

Code:
define dataset {&ppDatasetName}

  xml-node-name 'AUFTRAG':U

  &IF "{&ippNoReferenceOnlySwitch}" <> "YES"
  &THEN
  reference-only
  &ENDIF

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

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

fill dataset

Code:
PROCEDURE fillDataset :
/* Description ---------------------------------------------------------------*/
/*                                                                            */
/* Fuellt Dataset fuer den Export                                             */
/*                                                                            */
/*----------------------------------------------------------------------------*/
def input-output parameter dataset for dsAuftrag.

def var lvc_meldung as char no-undo.

MAIN:
do on error  undo MAIN, retry MAIN
   on endkey undo MAIN, return error:

  if retry
  then do:


  end. /* RETRY */

  /* Beispielexport */
  create ttAuftrag.
  assign
    ttAuftrag.firma            = '100'
    ttAuftrag.kunde            = 100002
    ttAuftrag.web_bestellnr    = 'abc123'
    ttAuftrag.bestellreferenz  = '12345'
    ttAuftrag.auftragsart      = ''
    ttAuftrag.lieferadresse    = '1'
    ttAuftrag.rechnungsadresse = '1'
    ttAuftrag.empfaenger       = 'empfänger'
    ttAuftrag.frachtkosten     = 12.50
    ttAuftrag.bemerkung        = 'Bemerkung'
    ttAuftrag.payment1         = 'Pay1'
    ttAuftrag.payment2         = 'Pay2'
    ttAuftrag.payment3         = 'Pay3'
    ttAuftrag.payment4         = 'Pay4'.

  create ttAufPos.
  assign
    ttAufPos.firma           = '100'
    ttAufPos.web_bestellnr = 'abc123'
    ttAufPos.positionsnr     = '1'
    ttAufPos.artikel         = '31105090-00'
    ttAufPos.menge           = 10
    ttAufPos.preis           = 412.50.

  create ttAufPos.
  assign
    ttAufPos.firma           = '100'
    ttAufPos.web_bestellnr   = 'abc123'
    ttAufPos.positionsnr     = '2'
    ttAufPos.artikel         = '50000000-00'
    ttAufPos.menge           = 1
    ttAufPos.preis           = 2.55.

end. /* MAIN */

end procedure. /* fillDataset */


Write XML

Code:
{y/gateway/incl/yg_auf00.pds
  &ippNoReferenceOnlySwitch = yes
}
{y/gateway/incl/yg_auf00.pds
  &ippNoReferenceOnlySwitch = yes
  &ippPostfix               = _rc
}



Main:
do
on error  undo Main, retry
on endkey undo Main, leave:

if retry
then do:
  message 'fehler'.
  leave.
end.


 {call dsAuftrag emptyDataset}.

  {call dsAuftrag fillDataset} .


  dataset dsAuftrag:write-xml('file':U,
                              'd:\temp'
                                + {&pa-backslash}
                                + 'Auftrag_Beispiel_':U
                                + string(year(today),'9999':U)
                                + string(month(today),'99':U)
                                + string(day(today),'99':U)
                                + '_':U
                                + replace(string(time,'hh:mm:ss':U),':':U,'_':U)
                                + '.xml':U,
                              yes,
                              'UTF-8':U,
                              '':U,
                              yes).

end. /* Main */


READ XML
Code:
{y/gateway/incl/yg_auf00.pds
  &ippNoReferenceOnlySwitch = yes
}
{y/gateway/incl/yg_auf00.pds
  &ippNoReferenceOnlySwitch = yes
  &ippPostfix               = _rc
}


Main:
do
on error  undo Main, retry
on endkey undo Main, leave:

if retry
then do:
  message 'fehler'.
  leave.
end.

gvc_vz = 'd:\temp\Auftrag_Beispiel_20171113_06_28_49.xml'.

gvh_ds = dataset dsauftrag:handle.

  gvl_ret = gvh_ds:read-xml('file':U,gvc_vz,?,?,false) no-error.



  if error-status:error
    or gvl_ret = false
  then do:

    do gvi_zaehler = 1 to error-status:num-messages:
        message error-status:get-number(gvi_zaehler)) error-status:get-message(gvi_zaehler).

    end. /* do lvi_zaehler = 1 to error-status:num-messages: */

  end. /* if error-status:error */



for each ttauftrag:
  /* THIS message don´t appears */
  message '1 auftrag'.

end.
for each ttaufpos:
  message '2 pos'.

end.

for each ttauftrag doesn´t appear. I seems like Read-XML have a problem with the top buffer?
 
#5
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.