1. ATK Gimmy Susan
  2. PowerBuilder
  3. Friday, 3 May 2019 07:46 AM UTC
Hi Guru.
I can't import a jason file (I extracted the code from the example 'json' which is found in codexchange)

I list the steps I take:

1. I export dw data in the (standard) format
ls_json = dw_1.Exportjson (true)

2. Import:
dw_1.DataObject = ""
ll_rc = dw_1.importjson (mle_1.Text, ls_errors)

esult:
ll_rc = null
ls_errors = ''

Why not recreate the Datawindows with data? I attach export file:
{"identity":"70c86603-983b-4bd9-adbc-259436e43cbd","version":1,"platform":"PowerBuilder","mapping-method":0,"dataobject":{"name":"dw_agente","meta-columns":[{"name":"cdagen","index":0,"datatype":"string","nullable":1},{"name":"cdazie","index":1,"datatype":"string","nullable":1},{"name":"cdagen_m","index":2,"datatype":"string","nullable":1},{"name":"dsagen","index":3,"datatype":"string","nullable":1}],"primary-rows":[{"row-status":0,"columns":{"cdagen":["0000000046"],"cdazie":["01"],"cdagen_m":["001"],"dsagen":["FAVERO MAURO"]}},{"row-status":0,"columns":{"cdagen":["0000000047"],"cdazie":["01"],"cdagen_m":["002."],"dsagen":["PASSARELLA CLAUDIO"]}},{"row-status":0,"columns":{"cdagen":["0000000048"],"cdazie":["01"],"cdagen_m":["003"],"dsagen":["FAVARO DINO"]}},{"row-status":0,"columns":{"cdagen":["0000000049"],"cdazie":["01"],"cdagen_m":["004"],"dsagen":["SCAPINELLO FAUSTO"]}},{"row-status":0,"columns":{"cdagen":["0000000050"],"cdazie":["01"],"cdagen_m":["005."],"dsagen":["EXXXX. CLAUDIO "]}},{"row-status":0,"columns":{"cdagen":["0000000051"],"cdazie":["01"],"cdagen_m":["006."],"dsagen":["STANGHERLIN GIORGIO"]}},{"row-status":0,"columns":{"cdagen":["0000000052"],"cdazie":["01"],"cdagen_m":["007"],"dsagen":["SEDE"]}},{"row-status":0,"columns":{"cdagen":["0000000053"],"cdazie":["01"],"cdagen_m":["008"],"dsagen":["CROSETTA MASSIMO"]}},{"row-status":0,"columns":{"cdagen":["0000000054"],"cdazie":["01"],"cdagen_m":["009"],"dsagen":["TOSO ROBERTO"]}},{"row-status":0,"columns":{"cdagen":["0000000055"],"cdazie":["01"],"cdagen_m":["011"],"dsagen":["NICHELE ANDREA"]}},{"row-status":0,"columns":{"cdagen":["0000000056"],"cdazie":["01"],"cdagen_m":["012"],"dsagen":["PIVETTA ETTORE"]}},{"row-status":0,"columns":{"cdagen":["0000000057"],"cdazie":["01"],"cdagen_m":["013"],"dsagen":["M.M. SAS DI FICHERA GIUSEPPE & C."]}},{"row-status":0,"columns":{"cdagen":["0000000058"],"cdazie":["01"],"cdagen_m":["014"],"dsagen":["D.L.D."]}},{"row-status":0,"columns":{"cdagen":["0000000059"],"cdazie":["01"],"cdagen_m":["015"],"dsagen":["GAZZETTA FLAVIO"]}},{"row-status":0,"columns":{"cdagen":["0000000060"],"cdazie":["01"],"cdagen_m":["017"],"dsagen":["D.L.D."]}},{"row-status":0,"columns":{"cdagen":["0000000061"],"cdazie":["01"],"cdagen_m":["018"],"dsagen":["A L I V E R "]}},{"row-status":0,"columns":{"cdagen":["0000000065"],"cdazie":["01"],"cdagen_m":["999"],"dsagen":["999"]}},{"row-status":0,"columns":{"cdagen":["0000000063"],"cdazie":["01"],"cdagen_m":["050"],"dsagen":["CLIENTI SOSPESI"]}},{"row-status":0,"columns":{"cdagen":["0000000064"],"cdazie":["01"],"cdagen_m":["016"],"dsagen":["SPIGA IMPEX S.L."]}},{"row-status":0,"columns":{"cdagen":["0000000066"],"cdazie":["01"],"cdagen_m":["051"],"dsagen":["RAS. ALDIS -RIMINI"]}},{"row-status":0,"columns":{"cdagen":["0000000067"],"cdazie":["01"],"cdagen_m":["052"],"dsagen":["FOOD DEALERS GROUP SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000068"],"cdazie":["01"],"cdagen_m":["053"],"dsagen":["EUROLANDIA SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000069"],"cdazie":["01"],"cdagen_m":["006"],"dsagen":["DE CARNE RAPP.ALIMENTARI"]}},{"row-status":0,"columns":{"cdagen":["0000000070"],"cdazie":["01"],"cdagen_m":["010"],"dsagen":["SAVIOZZI LEONARDO"]}},{"row-status":0,"columns":{"cdagen":["0000000071"],"cdazie":["01"],"cdagen_m":["002"],"dsagen":["MECCHIA ALESSANDRO"]}},{"row-status":0,"columns":{"cdagen":["0000000072"],"cdazie":["01"],"cdagen_m":["101"],"dsagen":["SORELLE TIDILI"]}},{"row-status":0,"columns":{"cdagen":["0000000073"],"cdazie":["01"],"cdagen_m":["105"],"dsagen":["FOOD VALLEY TRADING SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000074"],"cdazie":["01"],"cdagen_m":["107"],"dsagen":["XPORT SNC di ZERBINI & BIANCHI "]}},{"row-status":0,"columns":{"cdagen":["0000000075"],"cdazie":["01"],"cdagen_m":["108"],"dsagen":["BLUESHIP SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000076"],"cdazie":["01"],"cdagen_m":["005"],"dsagen":["BORDIGNON  S.R.L"]}},{"row-status":0,"columns":{"cdagen":["0000000077"],"cdazie":["01"],"cdagen_m":["019"],"dsagen":["M T Z CONSULTING SAS"]}},{"row-status":0,"columns":{"cdagen":["0000000078"],"cdazie":["01"],"cdagen_m":["100"],"dsagen":["TERENGHI ROBERTO"]}},{"row-status":0,"columns":{"cdagen":["0000000079"],"cdazie":["01"],"cdagen_m":["102"],"dsagen":["T.F.A. SAS"]}},{"row-status":0,"columns":{"cdagen":["0000000080"],"cdazie":["01"],"cdagen_m":["020"],"dsagen":["AL.MO. SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000081"],"cdazie":["01"],"cdagen_m":["021"],"dsagen":["PANERO MICHELA"]}},{"row-status":0,"columns":{"cdagen":["0000000082"],"cdazie":["01"],"cdagen_m":["054"],"dsagen":["FRUITSERVICE SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000083"],"cdazie":["01"],"cdagen_m":["023"],"dsagen":["FOODS FROM ITALY SNC-PAOLA MECCHIA &C"]}},{"row-status":0,"columns":{"cdagen":["0000000084"],"cdazie":["01"],"cdagen_m":["055"],"dsagen":["STUDIO BERTELLI SOC.UNIPERSONALE"]}},{"row-status":0,"columns":{"cdagen":["0000000085"],"cdazie":["01"],"cdagen_m":["024"],"dsagen":["CANSIGLIO S.A.S"]}},{"row-status":0,"columns":{"cdagen":["0000000100"],"cdazie":["01"],"cdagen_m":["030"],"dsagen":["BORTIGNON LORIS "]}},{"row-status":0,"columns":{"cdagen":["0000000088"],"cdazie":["01"],"cdagen_m":["109"],"dsagen":["TERUGGI SAS "]}},{"row-status":0,"columns":{"cdagen":["0000000089"],"cdazie":["01"],"cdagen_m":["022"],"dsagen":["BORDIGNON MATTEO "]}},{"row-status":0,"columns":{"cdagen":["0000000092"],"cdazie":["01"],"cdagen_m":["026"],"dsagen":["SOGREI CONSULT SL"]}},{"row-status":0,"columns":{"cdagen":["0000000096"],"cdazie":["01"],"cdagen_m":["027"],"dsagen":["ZAGHI C.G."]}},{"row-status":0,"columns":{"cdagen":["0000000099"],"cdazie":["01"],"cdagen_m":["058"],"dsagen":["VIVA SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000098"],"cdazie":["01"],"cdagen_m":["028"],"dsagen":["CORBETTA FERRUCCIO E MARCO SNC"]}},{"row-status":0,"columns":{"cdagen":["0000000091"],"cdazie":["01"],"cdagen_m":["056"],"dsagen":["CALDAROLA EMANUELE"]}},{"row-status":0,"columns":{"cdagen":["0000000103"],"cdazie":["01"],"cdagen_m":["031"],"dsagen":["LOGICAL SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000090"],"cdazie":["01"],"cdagen_m":["025"],"dsagen":["FOCA SNC DI FORNASARI & CATTABRIGA &C."]}},{"row-status":0,"columns":{"cdagen":["0000000097"],"cdazie":["01"],"cdagen_m":["057"],"dsagen":["MICO SRL"]}},{"row-status":0,"columns":{"cdagen":["0000000104"],"cdazie":["01"],"cdagen_m":["032"],"dsagen":["RIZZO A."]}}]}}
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 3 May 2019 16:39 PM UTC
  2. PowerBuilder
  3. # 1

Hi Gimmy;

  Ahhh  .. I see what you are trying to do ... export the JSON including the DWO's "meta-data" so that the ImportJSON() command could recreate the DWO again from the JSON meta-data. When you run your code though, you will see that the ExportJSON (TRUE ) command does not generate the DWO meta-data as per the PB Help (see below). Thus, there is no chance to the recreate the DWO on the ImportJSON() command.

----------------------------------------  From the PB Help ---------------------------------

A standard-format DataWindow JSON is an object that contains elements representing the various aspects of a DataWindow. For example:

{
  "identity": "70c86603-983b-4bd9-adbc-259436e43cbd",
  "version": 1,
  "platform": "PowerBuilder",
  "mapping-method": 0,
  "dataobject": {
    "name": "d_employee",
    "meta-columns": [
      {
        "name": "emp_id",
        "index": 0,
        "datatype": "long",
        "nullable": 1
      },
      {
        "name": "manager_id",
        "index": 1,
        "datatype": "long",
        "nullable": 1
      },

----------------------------------------------------------------------------------------------------------------

I believe this might be a PB bug for the missing meta-data when the "True" option is used on the export. I see your ticket in the Support System for this and have replied as well there.

Regards ... Chris

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 3 May 2019 19:25 PM UTC
Hi Gimmy;

FYI: Same issue in PB2019 Beta#2

Regards ... Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 3 May 2019 15:45 PM UTC
  2. PowerBuilder
  3. # 2

Hi Gimmy;

   Replace: dw_1.DataObject = ""

   With:   dw_1.Reset ()

Regards ... Chris

Comment
  1. ATK Gimmy Susan
  2. Friday, 3 May 2019 16:08 PM UTC
if I export with the 'Standard DataWindow JSON' method: dwcontrol.ExportJson (true)

Does Powerbuilder recreate the datawndows ?
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 3 May 2019 12:16 PM UTC
  2. PowerBuilder
  3. # 3

Try commenting out the first line of step2 where you set the dataobject to "" and it should work.  I tried importing your json and got the same thing with no dataobject, but when I had any dataobject assigned, it at least tried to fill the data where the column matched the format in the json.  It looks like you need a dataobject even if you do the standard format export (seems like a bug because all of the dwo info should be included in the standard format).

 

Are you experimenting or trying to take a full dw with data and display the contents in another without knowing the dataobject?  If that's what you are trying to do, just use GetFullState to a blob and SetFullState in the other datawindow.  Then you don't need the dwo in the second datawindow.  Let us know the "why" of what you are doing and we can recommend the best "how".

 

HTH,

Kevin

Comment
  1. ATK Gimmy Susan
  2. Friday, 3 May 2019 12:40 PM UTC
Hi Kevin

Ty for your answer.



I trying to take a full dw with data and display the contents in another without knowing the dataobject.
  1. Helpful
  1. Kevin Ridley
  2. Friday, 3 May 2019 13:08 PM UTC
OK I think I remember talking to you before and you are looking to migrate from EA Server so that makes sense. What you need is the GetFullState and SetFullState methods. That way you will only need the dataobject on the server datawindow. When you do the SetFullState on the client datawindow, you don't need any dataobject at all.



I'm actually thinking about doing a presentation for Elevate 2019 on EA Server migration to server components with PB 2019 and a PowerBuilder client.
  1. Helpful
There are no comments made yet.
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Friday, 3 May 2019 10:35 AM UTC
  2. PowerBuilder
  3. # 4

This is the simple code

Attachments (1)
Comment
There are no comments made yet.
DIPANJAN DUTTA Accepted Answer Pending Moderation
  1. Friday, 3 May 2019 10:07 AM UTC
  2. PowerBuilder
  3. # 5

Hi Gimmy,

Their is no problem in your Json export file. I have successfully Export in external DW.

Only in 2 case ImportJson methods return NULL

  • Any argument's value is null in ImportJson method
  • The DataWindow object (dataobject) is invalid

 

Following are the Step to export your file

1. Create External DW

2. Import Button Code

long ll_rc
string ls_errors

IF format = 0 THEN
dw_1.Reset()
ELSE
dw_1.DataObject = ""
END IF
MessageBox ( "Import", "DataWindow Cleared" )

ll_rc = dw_1.importjson( mle_1.Text, ls_errors )

IF ll_rc <> 0 THEN
MessageBox ( "Output Rows", String (ll_rc) )
END IF


IF ls_errors <> '' THEN
MessageBox ( "Errors", ls_errors )
END IF

 

===========Output==================

1. Before Click on Import

2. After Click on Import

 

Comment
  1. ATK Gimmy Susan
  2. Friday, 3 May 2019 10:49 AM UTC




Ty DUTTA for your answer, but i don't understand.



Why you create a datawindows external ?

In your import code i see ' dw_1.DataObject = "" '



Does the json file in standard format need the dw?



in standard format, is the datawindows dynamically reconstructed?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.