NetTalk Central

Author Topic: XML and Clarion Dates  (Read 7489 times)

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
XML and Clarion Dates
« on: March 06, 2016, 01:07:00 PM »
Hello

My data table has a date field that is a long and I format it on screen as D17.

A company Posting data into my web services uses a string for a DOB date, how can I get their date into the clarion date format?

I am thinking I need to provide them with another table column in the web service that is a string, is there another way?

Many thanks

Edwin

C10, NT 9.01
Windows 10 pro


Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #1 on: March 06, 2016, 05:15:52 PM »
Hi Edwin,

If I'm understanding correctly - then you'd use deformat(string,@d?) .. where @d? corresponds to the date string the company is sending to the web service.

That should return the date as a long.

If they're sending a datetime string, then you'd need to split the strings into date and time then use deformat(), although a dob value should just be a date string I'm guessing!
Cheers,

Stu Andrews

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #2 on: March 07, 2016, 05:22:44 AM »
Hi Stu

Thanks, I have expeimented recently by adding another column to my data table (string) and having them post the date info into that (AIP:LeadDOB1) then deformat that and assign to AIP:DOB1

BUT lets just say that I do not want to (or I should not have to) add any more columns to my data table, I have AIP:DOB1 (Long and screen format @D17) What does the sender post that date info to so I can get at it to deformat it :-)

If its not in the Table then as far as I can see it is not available for the sender to post to, can I make a local data / global data / session variable for them to post to?

OR is the string value they are sending (to my table date (Long)  available to me to deformat before it is assigned, if so where and how do I get at it

I am fairly new to all this xml / web stuff so any help is much appreciated

Many thanks

Ed

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #3 on: March 07, 2016, 11:17:04 PM »
Hey Ed,

Okay. So I might be way off base here, but .. The customer is using your webservice. They are sending xml to your webservice.

So you can right-click source edit your webservice procedure and get access to that xml BEFORE it goes to the file (I think).

My webservice stuff is almost all hand-coded (because they were put in before nettalk had it's wonderful webservice procedure), so I can't say it's 100% possible to do (someone else might be able to chip in).

The idea being that the xml comes in and is placed somewhere before being stuck in a file by the template. You want to find the code that does that, and do some magic before that (and possible overwrite the date xml string with your clarion long date.

Hope that's helpful.
Cheers,

Stu Andrews

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: XML and Clarion Dates
« Reply #4 on: March 08, 2016, 05:35:08 AM »

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #5 on: June 08, 2016, 08:20:25 AM »
Hi

Followed the advice and checked the docs on the link given and tried to implement but it does not work for me??

I am using the correct embed that I find in the getinfo (netwebpage) under the webhandler of my NT9.06 application, here is the contents of my embed (before parent call)

Formatting or Deformatting incoming XML fields !look here to manipulate xml data values such as a date string
!It is possible that an incoming XML field will need to be reformatted as it is being imported.
!For example the incoming xml may contain a date in yyyy/mm/dd format that needs to be converted to Clarion LONG format for use in a group,
!queue or table.
!
!The correct place to put this code is in the AssignField method. Note that here are two AssignField methods - !
!you need to embed in the one prototyped as
!
!xFileXML.AssignField Procedure (String pString)
!
!You can add code before the parent call which assigns the incoming pString parameter into  the appropriate field.
!The field currently being dealt with is in the CurrentTag property. For example;
!
!xFileXML.AssignField Procedure (String pString)
!  code
!  case lower(self.CurrentTag)
!  of 'date'
!    self.CurrentField = deformat(pString,@d10) ! yyyy/mm/dd
!    return ! this is important to avoid the call to PARENT
!  end
!  parent.AssignField(pString)

  case lower(self.CurrentTag) !this does not work - for some reason - 08/06/2016 - Ed
  of 'dob1' ! if I use CEN_DOB1 here I still get same result
    self.CurrentField = deformat(pString,@d6) ! dd/mm/yyyy
    return ! this is important to avoid the call to PARENT
  end
  parent.AssignField(pString)

**
I am sending the dob1 in xml as  <CEN_DOB1>14/06/1989</CEN_DOB1>

I could use a little help on this, Am I using the correct embed location?, does my code look ok

Please advise

Many thanks

Edwin

Edwin Hannan
Windows 10 Pro
Clarion 10.0.12104
Nettalk 9.06, StringTheory 2.43, xFiles 2.80, jfiles 1.19, selfservice 3.45, winevent 3.99, GPF Reporter 2.33



kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: XML and Clarion Dates
« Reply #6 on: June 08, 2016, 03:36:59 PM »
Hi Ed,

I think the currenttag or dob1 pstring is not returning what you think it is returning. Add a couple of traces as per below which hopefully will enlighten the situation for you.

p_web._trace('self.CurrentTag=' & self.CurrentTag)
case lower(self.CurrentTag) !this does not work - for some reason - 08/06/2016 - Ed
  of 'dob1' ! if I use CEN_DOB1 here I still get same result
    p_web._trace('dob1 pString=' & pString)
    self.CurrentField = deformat(pString,@d6) ! dd/mm/yyyy
    return ! this is important to avoid the call to PARENT
  end
  parent.AssignField(pString)

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #7 on: June 09, 2016, 02:59:24 AM »
Hi Kevin

Thanks for that but I still cant get this to work, perhaps I have the right embed on the wrong procedure

So which procedure should have access to this embed?, I have tried the web service database (added the xfiles extn so I can use the embeds for both my methodss...does not work.

So deleted that extn and inserted xfiles directly on the dbCentral webservice method extn, put code in the correct embed and still not working.

What am I doing wrong?

Please advise

Many thanks

Ed

Edwin Hannan
Windows 10 Pro
Clarion 10.0.12104
Nettalk 9.06, StringTheory 2.43, xFiles 2.80, jfiles 1.19, selfservice 3.45, winevent 3.99, GPF Reporter 2.33


Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #8 on: June 10, 2016, 12:27:00 AM »
Hi

Still not getting it, this is what I do to make it work (my work around)

** in Primefields

!I have the dob1 coming as as just numeric 14061989 for example this is 14/06/2016 if a string
!I then construct a date string as dd/mm/yyyy and deformat into a Clarion date and this works fine

LOC:Dob1 = Sub(q:central.cen_dob1,1,2) & '/' & Sub(q:central.cen_dob1,3,2) & '/' & Sub(q:central.cen_dob1,5,4)
cen:dob1 = DEFORMAT(LOC:Dob1,@D6) ! ******* THIS WORKSS 08/06/2016 - ED *******

! it seems to me that I need to get at the xml value string before it is assigned to the q:central so I can deformat it
! to a clarion date..tried the xfiles example - does not work for me..sent question to nettalk news group..08/06/2016 - Ed

Any help appreciated

Many thanks

Ed

Edwin Hannan
Windows 10 Pro
Clarion 10.0.12104
Nettalk 9.06, StringTheory 2.43, xFiles 2.80, jfiles 1.19, selfservice 3.45, winevent 3.99, GPF Reporter 2.33

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: XML and Clarion Dates
« Reply #9 on: June 14, 2016, 03:42:16 AM »
Hi Edwin,

I think you should roll back a bit to Kevin's point;

>> I think the currenttag or dob1 pstring is not returning what you think it is returning. Add a couple of traces as per below which hopefully will enlighten the situation for you.

perhaps do that, and then post here what the incoming tags actually look like.

Cheers
Bruce

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #10 on: June 15, 2016, 03:22:42 AM »
Hi Bruce

Still not getting it

Where exactly do I locate this embed, xFileXML.AssignField Procedure (String pString)?

I understand that the xml object needs to be referenced, in my app I do not see this embed / reference anywhere

If you were starting fresh with web77 example how would you locate this embed to insert the said code to change the value of an incoming value before it is assigned / primed in the queue.

Many thanks

Edwin






Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: XML and Clarion Dates
« Reply #11 on: June 16, 2016, 01:40:20 AM »
Hi Edwin,

>> I understand that the xml object needs to be referenced, in my app I do not see this embed / reference anywhere

If you need the xml embed points, then you need to add a local xFiles extension to the procedure. The object must be called
xml

Then you tell the method to _not_ generate the object itself (which it is currently doing) because the xFiles extension will do it.
Go to the properties for the WebServiceMethod, on the General tab tick _OFF_ the setting there to "Generate XML Object".

The xFiles extension generates all the embed points for overriding (or embedding in) methods. So then you can add the code that Kevin suggested.

I have added this to the docs as well for the 9.10 build, so thanks for the question.

Cheers
Bruce

Edwin Hannan

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
    • Email
Re: XML and Clarion Dates
« Reply #12 on: June 17, 2016, 12:06:29 AM »
Hi Bruce

Thanks for that

Cheers

Ed