How to us the NJXFILEUPLOAD2-control?

Hi,
I am new to Ajax for Natural and tried some things out.
What I am now working on is to upload TXT-files to ADABAS/Natural-Mainframe using the NJXFILEUPLOAD2-control

my problem is that it seems that XCIOBJECT.CONTENT is empty after upload - I checked this in the event “onUploadFinished”.

Is there to do anything else then press the upload button?
documentation says that the content should then be available in XCIOBJECT.CONTENT.
I want to display the content in a TEXT-control but there seems to be no content.

Or should I better use another control?

Thanks for your support!
Hermann

Hi Herman,

did you have a look at the sample FILEUD-P in the njxdemos?

Best Regards,
Christine

Hi Christine,

yes - I had a look at the example - but there is only written

VALUE U’myupload.onUploadFinished’
0500 /* Now you can access the file content in the
0510 /* XCIOBJECTS data structure and store it for
0520 /* instance in a database.

But the XCIOBJECTS.CONTENT(*) is empty in my case - so I am not sure what is the problem.

So the example is a combined one for up- and download - it’s not clear for me which parts are necessary for upload and which belong to download only
e.g. at the begin of the example there are some CALLNAT’s

CALLNAT “LOADFILE” ‘njx_buttonitemlist.pdf’ DOC1
CALLNAT “MAKEURL” XCIOBJECTS(*) DOC1 URL1 ‘njx_buttonitemlist.pdf’

I suppose that they are only necessary for download and not for upload - or is this wrong?

Best regards,
Hermann

Yes, right, that part is only for the download.

Did you test with the original example FILEUD-P?
Could you just enter the lines
PRINT XCIOBJECTS(1)
NEWPAGE
into the event handler myupload.onUploadFinished and verify the content this way?

This is the result of PRINT XCIOBJECTS(1)

147194q.txt application/txt

This seems to be the CONTENTID and CONTENTTYPE of XCIOBJECTS - but CONTENT is still empty, isn’t it?

When I run FILEUD-P the CONTENT is filled - but I see no difference to my program
and if the CALLNAT’s (LOADFILE, MAKEURL) are deactivated it also don’t work in FILEUD-P
so the CALLNATs are not only for the download :!: :?: :!:

Here is my program:
0050 DEFINE DATA LOCAL
0060 1 NJX_FILECONTENT
0070 2 CEXT (A) DYNAMIC
0080 2 CNAME (A) DYNAMIC
0090 2 CONTENTID (A) DYNAMIC
0100 2 CPATH (A) DYNAMIC
0110 1 NJX_KDKURZ (A) DYNAMIC
0120 1 NJX_TXTANZEIGE (A) DYNAMIC
0130 1 NJX_TXTKUVERTANSCHRIFT (A) DYNAMIC
0140 1 XCIOBJECTS (1:)
0150 2 CONTENT (B) DYNAMIC
0160 2 CONTENTID (A) DYNAMIC
0170 2 CONTENTTYPE (A) DYNAMIC
0180 *
0190 LOCAL
0440 1 BLOB (B) DYNAMIC
0450 1 URL (A) DYNAMIC
0460 *
0470 END-DEFINE
0480 *
0590 CALLNAT “LOADFILE” ‘njx_upload.txt’ BLOB
0600 CALLNAT “MAKEURL” XCIOBJECTS(
) BLOB URL ‘njx_upload.txt’
0610 *
0620 RESET BLOB
0630 *
0640 PROCESS PAGE USING “PLIMPORT”
0650 *
0660 DECIDE ON FIRST PAGE-EVENT
0670 VALUE U’nat:page.end’, U’nat:browser.end’
0680 /
Page closed.
0690 IGNORE
0700 VALUE U’btnKdSelektion’
0710 /* TODO: Implement event code.
0720 PROCESS PAGE UPDATE FULL
0730 VALUE U’njx_FileContent.onUploadFinished’
0760 PRINT XCIOBJECTS(1)
0770 NEWPAGE
0780 *
0960 PROCESS PAGE UPDATE FULL
0970 VALUE U’onBtnAbbrechen’
0980 ESCAPE MODULE
0990 VALUE U’onBtnImportieren’
1000 /* TODO: Implement event code.
1010 PROCESS PAGE UPDATE FULL
1020 NONE VALUE
1030 /* Unhandled events.
1040 PROCESS PAGE UPDATE
1050 END-DECIDE
1060 *
1070 END

I copied the subprograms MAKEURL and LOADFILE from SYSEXNJX to my library - but still not working.

BR,
Hermann

I am attaching a minimal example for the upload, maybe you could check this out?
Kind regards, Thomas
upload.zip (4.69 KB)

Hi Thomas,

same result as in my previous example:

147194q.txt application/txt

no CONTENT, just CONTENTID and CONTENTTYPE

Best regards,
Hermann

Hermann,

sorry for that. If this small example does not deliver the content, I can only recommend to go for a support request. It could turn out to be a platform or version issue.

Kind regards, Thomas

See zap NA95003.

Hi,

we installed the zap and it works now :slight_smile:
content is filled - which brings me to my next question

I uploaded a txt-file and want to analyze its content - how to do this?
I have to read line by line and do some actions

thanks and best regards,
Hermann

The uploaded file comes in form of a blob. If you know that it is a text file, you can move it into a text string, separate this into lines and work on the lines. Please see the attached working example.
Best regards, Thomas
upload2.zip (4.97 KB)

Unfortunately it doesn’t work :cry:

see attachment - encoding seems to have a problem …

BR,
Hermann

I see: The example works for Unicode data, but I assume you have codepage ISO-8859-1 on the client (which corresponds to CP819 on the host) and an EBCDIC codepage on the host. And I assume we are receiving the data on the host in the client codepage ISO-8859-1 (CP819). So we have to convert it to the host codepage first. I don’t have a mainframe at hand, but the attached example should do it. If not, could you please tell which codepages are active on client and host (system variable *CODEPAGE) and/or provide an example file? Thanks, best regards, Thomas
upload3.zip (5.1 KB)

is working :smiley:

just for info: *Codepage delivers: IBM01141

Many thanks and best regards,
Hermann