# Working with Adabas LB Fields and Natural for Ajax

**URL:** <https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, NaturalONE, Natural-for-AJAX, Natural-on-Windows-Unix\
**Created:** [June 13, 2012, 9:10pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730 "2012-06-13T21:10:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 13, 2012, 9:10pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/1 "2012-06-13T21:10:59Z")

</div>

Hello,

I would like to know how work with Adabas LB fields using Natural for Ajax.  
If I have access to some programs models, it will be very good.  
Some detailed documentation will help me, too.

Thank you!  
Neila Bueno

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [June 13, 2012, 9:48pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/2 "2012-06-13T21:48:42Z")

</div>

Neila,

what are you trying to use LOBs for ?

- Display images ?
- Up / download arbitrary “files” stored in Adabas ?
- … ???

Best regards,

&nbsp;&nbsp;&nbsp;Wolfgang

---

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 13, 2012, 9:58pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/3 "2012-06-13T21:58:49Z")

</div>

Hi Wolfgang,

I would like to know how to store/retrieve “files” (like images, .pdf, .doc, .xls, etc) into/from Adabas LB fields.

Thank you,  
Neila

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [June 15, 2012, 12:00am UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/4 "2012-06-15T00:00:36Z")

</div>

Neila, I only found one example for displaying a LB as an image,  
which involves writing the LB to a workfile and pass it to an image  
control.

I’ll keep looking and let you know if I find something.

---

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 15, 2012, 2:53pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/5 "2012-06-15T14:53:18Z")

</div>

Wolfgang,

Thank you for the feedback.

I’ve consulted the Empower System ([empower.softwareag.com](http://empower.softwareag.com)) and I found one example like this you are telling me.  
Studying the NJX documentation and SYSEXNJX library demo I found references about the follow controls: NJX:OBJECTS, NJX:NJXFILEUPLOAD2, NJX:NJXFILEDOWNLOAD, but I’m still in doubt about how to work with adabas LB fields using NJX, so I’ll keep studying the question too.

Neila

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [June 18, 2012, 10:02am UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/6 "2012-06-18T10:02:12Z")

</div>

My experience with Natural for AJAX is a bit outdated, but I can provide some generic information with examples in Natural for Windows.

1. create a file/FDT which includes LOBs (fields with Length set to 0 and Long Alpha set to LB)
2. when creating the Adabas file, specify a second file as the associated LOB file
3. run Adarep to verify that the LOB files exists
4. create a DDM, ensuring that the LOBs are defined as Dynamic and with Format Option LB
5. in the Natural Configuration Utility set the Database Type to ADA2 to support LOBs
6. create a Natural program to populate the file

```auto
DEFINE WORK FILE 1 'dir\filename.ext' TYPE "UNFORMATTED"
READ WORK 1 ONCE VIEW.PICTURE
STORE VIEW
```

1. create a Natural program to retrieve and display the LOBs
2. a. a standard program writes the image to a WORK file and invokes a Browser to display it (example attached)
3. b. a Natural for Windows program can use a Dialog to display the image from a Work file
4. c. NJX or Natural ONE can display the image on a Web page

The sample program, tested with Natural for Windows, retrieves images from the EMPLOYEES file supplied with SAG’s Demo database. As the report is being displayed, double-click a data line to render the associated image in Internet Explorer.

```auto
DEFINE DATA LOCAL
1 EMP VIEW EMPLOYE1
  2 PERSONNEL-ID
  2 FIRST-NAME
  2 NAME
  2 L@PICTURE
1 PIC VIEW EMPLOYE1
  2 PICTURE
1 #N (U20)
1 #M (I4) CONST <10>
1 #PID (A8/#M)
1 #RES (A250) INIT <'C:\ProgramData\Software AG\Natural\Natapps\Fuser\'>
1 #DIR (A250)
1 #CMD (A250)
1 #I (I4)
1 #J (I4)
END-DEFINE
SET KEY PF3 = '%.'
COMPRESS #RES
         *LIBRARY-ID
         '\res\'
    INTO #RES LEAVING NO SPACE
READ EMP BY PERSONNEL-ID
      WHERE L@PICTURE <> 0
  AT END OF DATA
    NEWPAGE
  END-ENDDATA
  ADD 1 TO #I
  ASSIGN #PID (#I) = EMP.PERSONNEL-ID
  #N := EMP.NAME
  DISPLAY
          EMP.PERSONNEL-ID
          EMP.NAME
          EMP.FIRST-NAME
          EMP.L@PICTURE
  IF #I = #M
    THEN
      NEWPAGE
  END-IF
  AT END OF PAGE
    INPUT (AD=O IP=F) 'Select employee'
    ASSIGN #J = *CURS-LINE - 6
    IF #J = 1 THRU #M
      THEN
        COMPRESS #RES
                 #PID (#J)
                 '.jpg'
            INTO #DIR LEAVING NO SPACE
        DEFINE WORK FILE 1 #DIR TYPE "UNFORMATTED" ATTRIBUTES "NOAPPEND"
        FIND PIC WITH PERSONNEL-ID = #PID (#J)
          WRITE WORK 1 VARIABLE PIC.PICTURE
          OPTIONS TQMARK=OFF
          COMPRESS 'cmd.exe /c '
                 - '"C:\Program Files\Internet Explorer\iexplore.exe"'
                   #DIR
              INTO #CMD
          OPTIONS TQMARK=ON
          CALL "SHCMD" #CMD "ASYNCH" "NOSCREENIO"
        END-FIND
    END-IF
    RESET #I
          #PID (*)
  END-ENDPAGE
END-READ
END
```

The images are written as “resources” in the current Natural library. (By default this is where Dialogs expect to find them.)

NB This example is not intended to provide production-ready logic, but to demonstrate image retrieval in as small a program as possible.  
[lob.docx](https://techcommunity.softwareag.com/uploads/short-url/npKQSALTOiZr6K7tMt44J9Lrgl4.docx) (338 KB)

---

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 19, 2012, 2:08pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/7 "2012-06-19T14:08:18Z")

</div>

Thank you, Ralph!  
I executed the examples you sent using Employees and I’m implementing a similar code using NJX for test.

---

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 22, 2012, 9:23pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/8 "2012-06-22T21:23:52Z")

</div>

Hi!

I managed to store and retrieve a image file into adabas LB field using NJX:OBJECTS and NJX:NJXFILEUPLOAD2 controls. See the source code bellow. But, update and delete doesn’t work. Some tip about this question?

- 

> Natural Source Header 000000

- :Mode S
- :CP
- \<Natural Source Header  
/\*\* Main program generated for  
/\*\* adapter \<:link TESTE/PAGE1-A\>.  
/\*  
/\*\* :author nbue  
/\*\* :version Generated by Natural for Ajax.  
/\*  
DEFINE DATA LOCAL  
1 ID\_IMAGEM (A) DYNAMIC  
1 INFO (A) DYNAMIC  
1 IMAGEURL (A) DYNAMIC /_INIT \<'C:\Neila'\>  
/_  
1 XCIOBJECTS (1:\*)  
2 CONTENT (B) DYNAMIC  
2 CONTENTID (A) DYNAMIC  
2 CONTENTTYPE (A) DYNAMIC
- 

1 UPLOAD\_IMAGEM  
2 CEXT (A) DYNAMIC  
2 CNAME (A) DYNAMIC  
2 CONTENTID (A) DYNAMIC  
2 CPATH (A) DYNAMIC  
\*  
1 BLOB (B) DYNAMIC  
1 URL (A) DYNAMIC  
\*  
1 LOB VIEW OF FILE-5  
2 AA-1 /\* A 5 N D  
2 LA-1 /\* A N LA/NB/NV  
2 LB-1 /\* A N LOB/NB/NV  
\*  
END-DEFINE  
\*  
PROCESS PAGE USING “PAGE1-A”  
\*  
DECIDE ON FIRST \*PAGE-EVENT

VALUE U’nat:page.end’  
/\* Page closed.  
IGNORE

VALUE U’onUpdate’

F0. FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
MOVE INFO TO LOB.LA-1  
UPDATE(F0.)  
END TRANSACTION  
END-FIND  
/\*  
END TRANSACTION  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’onSearch’  
FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
MOVE LOB.LA-1 TO INFO  
MOVE LOB.LB-1 TO BLOB  
CALLNAT “MAKEURL” XCIOBJECTS(\*) BLOB URL  
IMAGEURL := URL  
END-FIND  
PROCESS PAGE UPDATE FULL

VALUE U’onDelete’  
F2. FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
DELETE (F2.)  
END TRANSACTION  
END-FIND  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’onExit’  
STOP

VALUE U’onInsert’  
MOVE ID\_IMAGEM TO LOB.AA-1  
MOVE INFO TO LOB.LA-1  
STORE LOB  
END TRANSACTION  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM

PROCESS PAGE UPDATE FULL

VALUE U’onLimpar’  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’upload\_imagem.onUploadFinished’  
MOVE XCIOBJECTS.CONTENT(1) TO LOB.LB-1  
PROCESS PAGE UPDATE FULL

NONE VALUE  
PROCESS PAGE UPDATE

END-DECIDE  
\*  
END

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [June 23, 2012, 11:26am UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/9 "2012-06-23T11:26:04Z")

</div>

I can only assume your FINDs don’t return the record you are looking for,  
i.e. AA-1 doesn’t contain ID\_IMAGEM as expected, or your program doesn’t  
receive ID\_IMAGEM correctly, you will have to debug these aspects.

---

<div class="post-metadata">

**Author:** ![Neila\_Bueno](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/neila_bueno/32/476_2.png) [@Neila\_Bueno](https://techcommunity.softwareag.com/u/Neila_Bueno)\
**Post date:** [June 26, 2012, 10:12pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/10 "2012-06-26T22:12:14Z")

</div>

Hi,

I think I found a way to working with Adabas LB Fields and NJX.  
On this page I use the follow NJX controls: NJX:OBJECTS, NJX:NJXFILEUPLOAD2  
See the basic source code main program bellow.  
If somebody has a better solution, please post it here.

- 

> Natural Source Header 000000

- :Mode S
- :CP
- \<Natural Source Header  
/\*\* Main program generated for  
/\*\* adapter \<:link TESTE/PAGE1-A\>.  
/\*  
/\*\* :author nbue  
/\*\* :version Generated by Natural for Ajax.  
/\*  
DEFINE DATA LOCAL  
1 ID\_IMAGEM (A) DYNAMIC  
1 INFO (A) DYNAMIC  
1 IMAGEURL (A) DYNAMIC /_INIT \<'C:\Neila'\>  
/_  
1 XCIOBJECTS (1:\*)  
2 CONTENT (B) DYNAMIC  
2 CONTENTID (A) DYNAMIC  
2 CONTENTTYPE (A) DYNAMIC
- 

1 UPLOAD\_IMAGEM  
2 CEXT (A) DYNAMIC  
2 CNAME (A) DYNAMIC  
2 CONTENTID (A) DYNAMIC  
2 CPATH (A) DYNAMIC  
\*  
1 BLOB (B) DYNAMIC  
1 URL (A) DYNAMIC  
\*  
1 LOB VIEW OF FILE-5  
2 AA-1 /\* A 5 N D  
2 LA-1 /\* A N LA/NB/NV  
2 LB-1 /\* A N LOB/NB/NV  
\*  
END-DEFINE  
\*  
PROCESS PAGE USING “PAGE1-A”  
\*  
DECIDE ON FIRST \*PAGE-EVENT

VALUE U’nat:page.end’  
/\* Page closed.  
IGNORE

VALUE U’onUpdate’  
\*  
F0. FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
MOVE INFO TO LOB.LA-1  
MOVE BLOB TO LOB.LB-1  
UPDATE(F0.)  
END TRANSACTION  
END-FIND  
/\*  
END TRANSACTION  
RESET ID\_IMAGEM INFO BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’onSearch’

FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
MOVE LOB.LA-1 TO INFO  
MOVE LOB.LB-1 TO BLOB  
CALLNAT “MAKEURL” XCIOBJECTS(\*) BLOB URL  
IMAGEURL := URL  
END-FIND  
PROCESS PAGE UPDATE FULL

VALUE U’onDelete’

F2. FIND(1) LOB WITH AA-1 = ID\_IMAGEM  
DELETE (F2.)  
END TRANSACTION  
END-FIND  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’onExit’  
STOP

VALUE U’onInsert’

MOVE ID\_IMAGEM TO LOB.AA-1  
MOVE INFO TO LOB.LA-1  
MOVE BLOB TO LOB.LB-1  
STORE LOB  
END TRANSACTION  
RESET ID\_IMAGEM INFO BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’onReset’  
RESET ID\_IMAGEM INFO XCIOBJECTS(\*) BLOB URL IMAGEURL UPLOAD\_IMAGEM  
PROCESS PAGE UPDATE FULL

VALUE U’upload\_imagem.onUploadFinished’  
MOVE XCIOBJECTS.CONTENT(1) TO BLOB  
CALLNAT “MAKEURL” XCIOBJECTS(\*) BLOB URL  
IMAGEURL := URL  
PROCESS PAGE UPDATE FULL

NONE VALUE  
PROCESS PAGE UPDATE

END-DECIDE  
\*  
END

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:02pm UTC](https://techcommunity.softwareag.com/t/working-with-adabas-lb-fields-and-natural-for-ajax/100730/11 "2021-04-02T15:02:03Z")

</div>


