User:Heiko: Difference between revisions

From Try-AS/400
Jump to navigation Jump to search
(About to remove extension)
 
(62 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= About =
== About ==
This is [[User:Heiko|Heiko]]s personal page, in which he maybe shares some private information or collects bits for new articles.
This is [[User:Heiko|Heiko]]s personal page, in which he maybe shares some private information or collects bits for new articles.


== Personal information ==
=== Personal Information ===
[[User:Heiko|Heiko]] has been in IT since the 90s, but never worked with an AS/400...until 2019. He'll document his first steps in the hope they will be useful to others.
[[User:Heiko|Heiko]] has been in IT since the 90s, but never worked with an AS/400…until 2019. He'll document his first steps in the hope they will be useful to others.


= Ideas for new articles =
== Ideas for new articles ==
== Project Hello World ==
tbd
=== Preparations ===
Things you need:
* An working tn5250 terminal, connected and logged in
* maybe this as a primer or quick reference:
** [[Basic Commands]]
** [[UNIX-User's Cheater Table]]
** [[How to program an Application]]


=== Creating a physical file to hold the sources ===
== Articles to maintain ==
Every user has a personal library, like a home in an Linux environment. Since a user can have and use multiple libraries, the current (=default for all operations) is stored in <tt>*CURLIB</tt><ref>https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/rzarl/rzarlcurlib.htm</ref>.
* [[:Category:Programming]]
Because the value of <tt>*CURLIB</tt> can be changed by the screen you are currently working in, all following commands will contain my personal library name <tt>HKRETSCHME</tt>. If you are sure <tt>*CURLIB</tt> is set correctly, you can omit the library.
** [[99 Bottles Of Beer (using REXX)]]
 
** [[Hello World (using C)]]
This command creates a physical file named <tt>HELLO01</tt>:
** [[Hello World (using database, display file and RPG)]]
 
** [[Create a database and query it using ODBC from a linux machine]] <-- NEEDS A LOT OF WORK IN THE PHP DEPARTMENT!
CRTSRCPF FILE(HKRETSCHME/HELLO01) RCDLEN(112) TEXT('Project Hello World')
 
But I prefer to do this in more steps, which I'd recommend to every beginner (By the way: don't bother using cases, the AS/400 won't either. Using capital commands and names just makes it more readable in this article.):
 
CRTSRCPF
If you don't give any parameters for this command, you will be asked. This works great for <tt>CRTSRCPF</tt>, but in general, OS/400 will only ask for '''necessary''' arguments. Some commands, like <tt>CHGUSRPRF</tt> will just do nothing.
This always works:<br/>'''''Enter the command you want to execute and then hit <tt>F4</tt>'''''.
 
[[Image:HelloWorld01CRTSRCPF.png|666px]]
 
==== A small detour: Physical Files? ====
[[User:Heiko|Heiko]] struggled a lot with this and thinks a small introduction is necessary:
* <tt>Libraries</tt>: Every user has his own personal library, think of it like a Linux home directory. [https://en.wikipedia.org/wiki/AS/400_library Details]
* <tt>Physical Files</tt>: Of course this is no physical file and you can't touch it. And don't think of if (like I as a german<ref>Yes, as a german IT guy you think of "file" as "Datei". But "file" in english can also mean "Akte" or "Karton mit Akten". Sorry for Kauderwelsch.</ref> do) as one file (f.e. <tt>/etc/passwd</tt>), it's more like an collection of informations, like you might know from MacOS resources.
* <tt>Members</tt>: A member is a file in an physical file, like a book in a filing box. Members of a physical file share the given structure of the PF. Record structure, field lengths, etc.
 
A more visal approach of explaining:<br/>
[[Image:PhysicalFileOrWhat.png|400px]]
 
The <tt>Library</tt> is the room you keep your <tt>Physical Files</tt> (like filing boxes) in. The <tt>Physical Files</tt> contain <tt>Members</tt> (like books) but must be the same size (okay, a crude explanation for the "must share structure" approach).
 
* You can have as much rooms, filing boxes and books as you want.
* But you can't put rooms in rooms, boxes in boxes or books in books<ref>And as you may have guessed, you can't put rooms in boxes, boxes in books&#x2026;</ref>.
* The AS/400 has no tree-like storage structure, it is just a list (of Libraries) with a limited depth (Physical Files and Members) to unfold:<br/>[[Image:PhysicalFileList.png]]
 
=== Creating the database ===
The procedure is as follows:
* create a text file describing the database
* compile it into a database
 
==== Creating the DDS ====
The textual description of a database is called DDS. You can learn more [https://www.ibm.com/support/pages/data-transfer-creating-physical-file-using-dds here about DDS] and [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rzakc/rzakcdatel.htm here about the DDS format and database fields].
 
* Input this to work with our just created Source Physical File:<br/>[[Image:Hello01wrkmbrpdm01.png|400px]]<br/><code>wrkmbrpdm file(hkretschme/hello01)</code>
* Hit <code>F6</code> to create a new member:<br/>[[Image:Hello01wrkmbrpdm01a.png|400px]]
* This will run STRSEU:<br/>(Input member name and type <code>PF</code>)<br/>[[Image:Hello01wrkmbrpdm02.png|400px]]
* Which brings you to SEU:<br/>(Enter text as shown)
        ***************** Datenanfang *******************************************************************************************
0001.00      A          R MESSAGES                                                                              191001          means: <code>A</code>dd<ref>I know, <tt>A</tt> stands alphanumeric. But <tt>Add</tt> is no much better to remember. :)</ref> <code>R</code>ecord named <code>MESSAGES</code>
0002.00      A            TEXT          42A                                                                      191001          means: <code>A</code>dd field named <code>TEXT</code> with <code>42</code> bytes of <code>A</code>scii.
0003.00      A          K TEXT                                                                                  191010          means: Make the field <code>TEXT</code> the key.
        ******************Datenende *********************************************************************************************
* Enter <tt>Y</tt> (here: <tt>J</tt>) to save the member.<br/>[[Image:Hello01wrkmbrpdm04.png|400px]]<br/>After saving, check the lower lines for messages. If there is a synthax error, return to SEU and check every line.<br/>'''''Hint: Use <code>F4</code> for assistance while coding!'''''
 
==== Creating the database physical file ====
* While working with PDM, enter <code>14</code> to compile the database.<br/>[[Image:Hello01wrkmbrpdm05.png|400px]]
* The compiling will be queued&#x2026;<br/>[[Image:Hello01wrkmbrpdm06.png|400px]]
* &#x2026;and you have to check with <code>DSPMSG</code> whether it was successful or not<ref>Can anyone tell me how this is done synchronously? Performance isn't an issue any more&#x2026;</ref>
Hint: Checking my messages with DSPMSG only showed me it wouldn't compile. No error message or any other useful information. If you run into trouble, double check your DDS in SEU, using <code>F4</code> on every single line. And remember the AS/400 is picky. Even an empty line is enough cause to abort compilation.
* If compilation worked out, you can see your compiled database physical file here:<br/><code>wrklib + <F4></code>
* Enter <code>5</code> to show contents of your library
* And here it is:<br/>[[Image:Hello01wrkmbrpdm10.png|400px]]<br>It is named <code>HELLO</code>, named after the DDS Member we compiled<ref>If we had chosen the same name for the member as for the source physical file, the PDM would have asked, if I'd want to overwrite the source physical file with the compiled database. Naming the member differently avoided this. This has the advantage that the DDS member remains for later use.</ref>.
 
=== Insert content into the database ===
* <code>STRSQL</code> + <code>F4</code>
** Enter the library name, in this example <code>HKRETSCHME</code><ref>Shortcut: <code>STRSQL LIBOPT(HKRETSCHME)</code></ref>
* In the interactive SQL session, enter: <code>INSERT INTO  HELLO (TEXT) VALUES ('Hello World!')</code>
* There are many ways to display the result:
** If you're still in STRSQL, enter: <code>SELECT * FROM HELLO</code>
** On command line, try this: <code>DSPF FILE(HKRETSCHME/HELLO)</code>
 
=== Display the content ===
==== Create a display file ====
A Display File (device) is a template for displaying your content.
* Read [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzakc/displ.htm this] and [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/cl/crtdspf.htm this] about creating DISPLAY FILES (DSPF)
* <code>CRTDSPF</code> followed by <code>F4</code>
** Enter target file and library (I used: <code>HELLODSP</code>, <code>HKRETSCHME</code>), which will result in a newly created Display File named <tt>HELLODSP</tt>)
** Enter source file, library and DDS member (in this example: <code>HELLO01</code>, <code>HKRETSCHME</code> and <code>HELLO</code>)
** Press &#x23CE;
* Then I ran into an problem: The DSPF wasn't created and I couldn't locate the error message. Depending on your system's configuration you will find them in your Print-Queue (use <code>WRKOUTQ</code>!), or even printed out on a printer. In my case, a PDF is created and showed the following:
 
After some hours, I got it right:
    Spalten . . . :    1 100                                    Editieren                                          HKRETSCHME/HELLO01
    SEU==>                                                                                                                  HELLODSPF
    FMT DP .....AAN01N02N03A.Name++++++RLängeDDsFZeiPosFunktionen++++++++++++++++++++++++++ ...+... 9 ...+... 0                     
        ***************** Datenanfang ******************************************************************************************* 
  0001.00                                            <font color="red">REF(HKRETSCHME/HELLO)</font>                                        191007           
  0002.00      A          R MESSAGES<font color="red">_</font>                                                                              191007           
  0003.00      A            TEXT      <font color="red">R</font>  42A  <font color="red">O  5  3</font>                                                            191007           
          ******************Datenende ********************************************************************************************* 
I copied the DDS Member to a new Member named HELLODSPF, changed the type to DSPF, and added the red characters.
Explanation:
* the first row to indicate this refers to a database physical file<ref>Beginning with column 45</ref>
* the record is named slightly differently than in the DDS, using a trailing "_".
* <code>R</code> to mark this field als reference<ref>Column 29</ref>
* <code>O</code> to mark this field als output<ref>Column 38</ref>
* <code>5  3</code> to locate the field in row 5, column 3 of the output screen<ref>Row: 39-41, column: 42-44</ref>
If you struggle with the positions of the keywords, have a look at IBM's <tt>DDS Reference</tt> (PDF) (I used Version 4), the 708 pages are packed with great screenshots and explanations.
 
Finally, <code>14</code> to compile XOR <code>CRTDSPF FILE(HKRETSCHME/HELLODSP) SRCFILE(HKRETSCHME/HELLO01) SRCMBR(HELLODSPF)</code> worked out:<br/>
[[Image:HelloWorldCRTDSPFOK.png|400px]]
 
==== Create the program ====
Now it's getting clear, that the whole design follows the [https://en.wikipedia.org/wiki/Model–view–controller MVC Paradigma]:
* Database Physical File => Model
* Display File => View
* Program<ref>Short: PGM</ref> => Controller
 
You can create programs in many languages: CL, REXX, C, COBOL and most commonly used, RPG.
 
Let's create a RPG:
* <code>WRKMBRPDM</code>
* Press <code>F6</code> to create a new <tt>RPGLE</tt> file called <code>HELLORPG</code>
* Enter this code:
        ***************** Datenanfang *******************************************************************************************
0001.00 F* Program for reading one row from database and write it do display                                191008             
0002.00 FHELLO    IF  E          K DISK                                        Def. DB PF              191010             
0003.00 FHELLODSPF CF  E            WORKSTN                                      Def. DSPF                191010             
0004.00 C                  READ      MESSAGES                                    Read 1 row              191010             
0005.00 C                  WRITE    MESSAGES_                                    Print 1 row              191010             
0006.00 C                  READ      MESSAGES_                                    Wait for input (key)    191010             
0007.00 C                  RETURN                                                End program              191008             
        ******************Datenende *********************************************************************************************
* Use <code>14</code> to compile><ref>If it doesn't check <code>DSPSMG</code> and, most importantly, your queues with <code>WRKOUTQ</code>. In my case, the compilation reports will be filed as PDF in my home.
* Run the program with: <code>CALL HKRETSCHME/HELLORPG</code>:<br/>[[Image:HelloWorldRPGFinallyDone.png]]
 
 
 
 
TODO: MOVE THIS TO --> [[Beginners Project: Hello World (using database and display file)]]
 
= Project: Access database with ODBC =
== Create a database ==
I suggest you try [[Beginners Project: 99 Bottles Of Beer (using REXX)]] and [[Beginners Project: Hello World (using database and display file)]] before you try this!<ref>[[User:Heiko|Heiko]] made this pretty brief, f.e. not every <code>F3</code> or <code>&#x23CE;</code> is noted.</ref><br/>
=== Create a database to play with ===
* This is the third project [[User:Heiko|Heiko]] did, so his personal Library was getting a bit cluttered. Therefore, let's create a library just for this niew project:
** <code>CRTLIB LIB(ODBC) TEXT(Library for ODBC project)</code>
* <code>CRTSRCPF FILE(ODBC/ODBCDB) RCDLEN(112) TEXT('Project ODBC and Database')</code> to create new physical file to hold the DDS.
* <code>WRKMBRPDM FILE(ODBC/ODBCDB)</code> Work with this file.
* <code>F6</code> to create new member, insert member's name and type <code>PF</code>:<br/>[[Image:ODBCDB01.png|400px]]
* Enter this DDS: ([https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rzakc/rzakcdatel.htm Learn what the below means])
        ***************** Datenanfang *******************************************************************************************
0001.00      A          R CALLS                                                                                  191002         
0002.00      A            CALLER        42A                                                                      191002         
0003.00      A            CALLED        42A                                                                      191002         
0004.00      A            DATE            L                                                                      191002         
0005.00      A            TIME            T                                                                      191002         
0006.00      A            TIMESTAMP      Z                                                                      191002         
        ******************Datenende *********************************************************************************************
* <code>14</code> to compile&#x2026;<br/>[[Image:ODBCDB02.png|400px]]<br/>&#x2026;I failed again. Stupid me. I can't create a new physical database file in the same place, where source physical file (with the same name!) exists.
** Just rename the DDS member from <code>ODBCDB</code> to <code>ODBCDBPF</code>:<br/>[[Image:ODBCDB03.png|400px]]<br/>[[Image:ODBCDB04.png|400px]]
** And try again.
** Check with <code>DSPMSG</code><ref>or use [[Compile Sources Without Queuing]]</ref> whether the compile was successful or not. If it did, you find the new PF in the library:<br/>[[Image:ODBCDB10.png|400px]]
 
=== Insert content into the database ===
 
HIER WEITERMACHEN!
 
* <code>STRSQL</code> + <code>F4</code>
** Enter the library name, in this example <code>ODBC</code><ref>Shortcut: <code>STRSQL LIBOPT(ODBC)</code></ref>
* In the interactive SQL session, enter: <code>INSERT INTO CALLS (CALLER, CALLED, TIME, DATE, TIMESTAMP) VALUES ('Ernie', 'Bert', 2019-10-05, '23:23', '2019-10-05 23:23:42')</code><ref>Timestamp format: https://www.ibm.com/support/knowledgecenter/SSFMBX/com.ibm.swg.im.dashdb.sql.ref.doc/doc/r0007107.html</ref>
* There are many ways to display the result:
** If you're still in STRSQL, enter: <code>SELECT * FROM CALLS</code>
** On command line, try this: <code>DSPF FILE(ODBC/ODBCDBPF)</code>
** Or use <code>STRDFU</code>, select option 5 and fill out the displayed form.
 
= Articles to maintain =
* [[Beginners Project: 99 Bottles Of Beer (using REXX)]]
* [[Beginners Project: Hello World (using C)]]
* [[Editing Source Files using Eclipse and FTP]]
* [[Editing Source Files using Eclipse and FTP]]
* [[Compile Sources Without Queuing]]
* [[Compile Sources Without Queuing]]
* [[How to solve Variadic Arguments issue (using C)]]


== Too many F-Keys to memorize ==
I'm using a small apple keyboard on which the F-keys aren't labeled very well. This helps a lot:


[[Image:F-Tasten F13-F24 v2 Photo.jpg|666px]]
You can download it here: [[File:F-Tasten F13-F24 v2.pdf]]


== Sandbox ==
== Sandbox ==
Line 243: Line 83:
</p>
</p>


=== Using (not-working) console-tag ===
== See also ==
<console>
* [[Basic Commands]]
Test
</console>
 
<console>
 
                                  Anmelden           
                                              System  . . . . . :  SLVRLAKE
                                              Subsystem . . . . :  QINTER
                                              Bildschirm  . . . :  QPADEV0004
                Benutzer  . . . . . . . . . . . .           
                Kennwort  . . . . . . . . . . . .
                Programm/Prozedur . . . . . . . .           
                Men}  . . . . . . . . . . . . . .           
                Aktuelle Bibliothek . . . . . . .           
                                        (C) COPYRIGHT IBM CORP. 1980, 2013.
</console>


----
== Footnotes ==
* Links
** [[Basic Commands]]
* References:
<references/>
<references/>
[[Category:Basic Knowledge]]

Latest revision as of 16:41, 14 April 2024

About

This is Heikos personal page, in which he maybe shares some private information or collects bits for new articles.

Personal Information

Heiko has been in IT since the 90s, but never worked with an AS/400…until 2019. He'll document his first steps in the hope they will be useful to others.

Ideas for new articles

tbd

Articles to maintain

Too many F-Keys to memorize

I'm using a small apple keyboard on which the F-keys aren't labeled very well. This helps a lot:

F-Tasten F13-F24 v2 Photo.jpg

You can download it here: File:F-Tasten F13-F24 v2.pdf

Sandbox

Screen mit MW-Bordmitteln

                                  Anmelden            
                                              System  . . . . . :   SLVRLAKE
                                              Subsystem . . . . :   QINTER
                                              Bildschirm  . . . :   QPADEV0004

               Benutzer  . . . . . . . . . . . .             
               Kennwort  . . . . . . . . . . . .
               Programm/Prozedur . . . . . . . .             
               Men}  . . . . . . . . . . . . . .             
               Aktuelle Bibliothek . . . . . . .             













                                       (C) COPYRIGHT IBM CORP. 1980, 2013.

Und nun Screen mit Bordmitteln und etwas HTML-Foo

Anmelden
System . . . . . : SLVRLAKE
Subsystem . . . . : QINTER
Bildschirm . . . : QPADEV0004

Benutzer . . . . . . . . . . . .
Kennwort . . . . . . . . . . . .
Programm/Prozedur . . . . . . . .
Men} . . . . . . . . . . . . . .
Aktuelle Bibliothek . . . . . . .













(C) COPYRIGHT IBM CORP. 1980, 2013.

See also

Footnotes