How to Copy MEMPTR to/from a LONGCHAR variable with out gett

Posted by Hema Ravi Teja Bollam on 17-Mar-2016 11:09

while copying the value of a MEMPTR to a LONGCHAR variable using GET-STRING, i got an error 9324 . Is there any solution ?

All Replies

Posted by Garry Hall on 17-Mar-2016 11:57

Use COPY-LOB.

Posted by Garry Hall on 17-Mar-2016 12:00

Sorry, I had not realised this is duplicate of community.progress.com/.../23797, which is already answered.

Posted by gus on 17-Mar-2016 13:10

note that a longchar is supposed to contain/characters/.

a blob can contain anything, including nulls.

nulls are not allowed in char or longchar, regardless of the character set, ecept as the very last byte.

Posted by Hema Ravi Teja Bollam on 18-Mar-2016 03:12

thansk guys!

Posted by Hema Ravi Teja Bollam on 18-Mar-2016 04:39

Hi all,

I tried , but in vain .Scenario is as follows ,

function x returns longchar():

 DEF VAR i_xml_string AS LONGCHAR NO-UNDO.

 DEF VAR i_mem        AS MEMPTR   NO-UNDO.

 p_doc:SAVE("memptr":U, i_mem).

 COPY-LOB FROM i_mem TO i_xml_string.

 return i_xml_string.

end.

below is the error log,

[16/03/17@10:20:58.984-0700] P-009824 T-000001 3 4GL 4GLTRACE   Return from ConvertXmlDocToLongString "<LONGCHAR>" [yeai/ye508mu.p]

[16/03/17@10:20:58.984-0700] P-009824 T-000001 1 4GL -- (Procedure: 'GenerateT5008xmlCusipSummaryRecord yeai/ye508mu.p' Line:2536) Attempt to exceed maximum size of a CHARACTER variable. (9324)

[16/03/17@10:20:58.984-0700] P-009824 T-000001 1 4GL -- (Procedure: 'GenerateT5008xmlCusipSummaryRecord yeai/ye508mu.p' Line:2536) ** Unable to evaluate expression for PUT statement. (564)

[16/03/17@10:20:58.984-0700] P-009824 T-000001 3 4GL 4GLTRACE   Return from GenerateT5008xmlCusipSummaryRecord "? tmp_cusip_tots yes " [yeai/ye508mu.p]

i could not achieve the functionality . pl. suggest , thanks i advance .

Regards,

Ravi

Posted by ankitshukla on 18-Mar-2016 05:40

If you want to use you xml to save into LONGCHAR then why don't you use

p_doc:SAVE("longchar":U,i_xml_string).

it will give you your xml into longchar after it you can write it into a file (if you want )

copy-lob from i_xml_string to file "test.xml".

Posted by Liliana Santiesteban on 18-Mar-2016 06:41

Hi,

I also have a problem with the .xml

I created the LongChar with TEMP-TABLE: WRITE-XML (), but now I use hDoc: SAVE ("LongChar": U, longstring).

The xml went well structurated on each line when using the temp-table but now with hDoc: SAVE ("LongChar": U, longstring) it does not come out well organized in the text editor,

How can I solve this ?

Regards,

Liliana

Posted by ankitshukla on 18-Mar-2016 07:28

Hi Liliana Santiesteban

Temp-table approach is different. Try with hDoc: SAVE ("file": U, "test.xml").

Posted by Liliana Santiesteban on 18-Mar-2016 07:41

Hi,

I need to create a LongChar.

How can I give a format before use the sentence  hDoc: SAVE ("LongChar": U, longstring)?

Posted by Garry Hall on 18-Mar-2016 08:29

The log output does not correspond to the code snippet: you have function x, but the log shows function ConvertXmlDocToLongString. If x is the same function as ConvertXmlDocToLongString, then the COPY-LOB did not fail. What failed was what you did with the returned LONGCHAR in GenerateT5008xmlCusipSummaryRecord.

Posted by ankitshukla on 18-Mar-2016 08:31

Hi Liliana,

see example below: a sample xml for your reference

def var lv-refxml  as handle no-undo.
def var lv-refroot as handle no-undo.
def var lv-refnode as handle no-undo.
def var lv-hText   as handle no-undo.
def var lv-longchar as longchar no-undo.

create x-document lv-refxml.
create x-noderef  lv-refroot.
create x-noderef  lv-refnode.

lv-refxml:CREATE-NODE(lv-refroot,"root","ELEMENT").
lv-refxml:APPEND-CHILD(lv-refroot).

lv-refxml:CREATE-NODE(lv-refnode,"child1","ELEMENT").
lv-refroot:APPEND-CHILD(lv-refnode).

create x-noderef lv-hText.

lv-refxml:create-node(lv-hText, "", "TEXT").
lv-refnode:append-child (lv-hText).

lv-hText:node-value = "Child-1".

delete object lv-hText.

lv-refxml:CREATE-NODE(lv-refnode,"child2","ELEMENT").
lv-refroot:APPEND-CHILD(lv-refnode).

lv-refnode:set-attribute("value","Child-2").

lv-refxml:SAVE("longchar",lv-longchar).

copy-lob from lv-longchar to file "example.xml".

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

/* OUTPUT */

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

<?xml version="1.0" ?>

<root>

   <child1>Child-1</child1>

   <child2 value="Child-2"/>

</root>

-

Thanks,

Ankit

Posted by Liliana Santiesteban on 18-Mar-2016 09:02

Thanks Ankit!

This thread is closed