Menu

GnuCOBOL TUI Tools Collection: 71 "CRUDE Application" Create Read Update Delete

2017-05-24
2017-05-29
  • Eugenio Di Lorenzo

    "CRUDE" applications allow you to create, read, update, and delete indexed file records. These files have a primary key that never allows duplicates and may have alternative keys that may or may not have duplicates.
    They can be master record type files (customer records, suppliers, accounts, materials ...) or any other type, such as transactional (accounting records, invoices issued, purchase orders, stock movements, and so on).
    AFAIK, this is the first available example of a CRUDE application on indexed files in GnuCOBOL.

    In this example, the CRUDE application manage an INDEXED FILE with a primary key and 3 alternative keys that do not allow duplicate values.

    The primary key in this application is a simple 9-digit numerator from 1 onwards without any meaning. It is like a GUID.

    This way, you can have keys that can be modified (the alternativ ekeys) without being forced to erase the record and rewrite it as it is mandatory for primary keys that can never be modified.

    This TUI tool is also a fully functional real working application.
    This sample CRUDE tool manages a FILE with master data.

    Duplicate these programs, keeping the general logic to manage other customer, supplier, accounts, materials master files or other transactional file files (accounting records, inventory movements, and so on). This way you can create virtually any kind of application.
    These files have a similar structure, that is, a primary key with a simple counter and secondary keys according to different needs (codes, descriptions ...).

    The application is designed to wokr and allow in a "multiple companies environment".
    In the example we handle more GC71Fxxx.DAT files where "xxx" is a code associated with a certain company code.

    This application uses other TUI TOOLS such as MENU, BOX, BOXMEX, DATEPICKER, BUTTONS, YESNO.

    The CRUDE application consists of four programs
    1. GC71CRUDEMAIN.cob: displays a cover and manages menus.
    2. GC71CRUDESEL.cob : allows multi-company and multi-file management.
    3. GC71CRUDEBRO.cob : to browse each of the files. it allows to link GC71CRUDE CUD for creation, edit and delete operations.
    4. GC71CRUDECUD,cob : performs both creating and editing and deleting records

    The application starts with a GC71CRUDEMAIN Menu with only two options: CREATE and READ (Browse). The Browse program allows selecting a record to be updated or deleted, or creating a new record.

    GC71CRUDEMAIN allows the user to select the Browse or Create function.
    In both cases, the GC71CRUDESEL program is called, which allows you to select which file (that is, the company code) and then in turn calls GC71CRUDEBRO to have the records list to browse or the GC71CRUDECUD program for creating a new record.

    GC71CRUDEBRO lists the records already in the file. Lets you scroll vertically and horizontally within the file and select a record that is managed in edit or delete from the same program GC71CRUDECUD. You can increase or decrease the amount of scrolling columns with + and - keys.

    GC71CRUDECUD allows you to create a new record or edit or delete an existing record.
    It contains lot of samples on how user input can be managed with various types of fields, mandatory fileds, date fields, numeric fileds, amount fields. How to decode user input. And it shows various types of controls, and how to link a datepicker to select date for date fields.
    It contains examples of how to enter amounts with integer and decimal digits and with a negative sign and how to check it.
    It also contains the example of link to have help on fields using the TUI GC74HELPVIEW tool.

    The general operating schema of the CRUDE application is as follows.

                          GnuCOBOL C.R.U.DE APPLICATION (CREATE READ UPDATE DELETE)
    
                            MENU                                         (browse)
                       .--- BROWSE Func= R ---.                   .--> GC71CRUDEBRO ---. <--.
                       |                      |                   |                    |    |
       GC71CRUDEMAIN --+                      |--> GC71CRUDESEL --|                   C/U/D |return
                       |    MENU              |                   |                    |    |
                       '--- CREATE Func= C ---'                   '--> GC71CRUDECUD <--' ---'
                                                                  (create/update/delete)
    

    Source files are in contributions/trunk/tools/TUI-TOOLS.
    In same folder are .DAT files GC71FALI.DAT,and GC71FALI.DAT.1 / 2 / 3 (alternative index files).and a PDF with screenshots.
    Comments and suggestions are welcome.

    @Brian this post is in the wrong forum. Could you move it to the "Contribution" forum ? Thx.

     

    Last edit: Eugenio Di Lorenzo 2017-05-29
    • Brian Tiffin

      Brian Tiffin - 2017-05-28

      @Brian this post is in the wrong forum. Could you move it to the "Contribution" forum ? Thx.

      Done. And thanks for all the efforts, Eugenio. Awesome.

       
  • Brian Tiffin

    Brian Tiffin - 2017-05-28

    Rats. Seems the move borked all the attachments. You'll probably need to fix those manually, Eugenio.

    There are no options on the move screen, so I'm counting it as a bug in Allura.

    Sorry,
    Brian

     

    Last edit: Brian Tiffin 2017-05-29
    • Simon Sobisch

      Simon Sobisch - 2017-05-29

      @Brian: can you check if Allura has a bug report for this already and create it if it hasn't one?
      The bug was that:
      URL of thread changed as requested (the only part was the discussion board "help" to "contrib")
      URL of attached files did changed, too
      * files were not re-located, still available on the old URL https://sourceforge.net/p/open-cobol/discussion/help/thread/f5934f0f/dbed/attachment/GC71-33-CRUDEBRO.png

       
  • Brian Tiffin

    Brian Tiffin - 2017-05-29

    No luck here either. Sorry. Not sure what to suggest next. Learned not to move threads with attachments, but not sure the best way forward on this one.

    Brian

     
    • Eugenio Di Lorenzo

      Resolved! I simply attached the same files again.

       
      • Simon Sobisch

        Simon Sobisch - 2017-05-29

        Looks like I've interferred GC71-30-CRUDEBRO.png and it needs another re-upload.

         
        • Eugenio Di Lorenzo

          done.
          go to Contributions / trunk / tools / TUI-TOOLS / GC71CRUDEDOC-SCREENSHOTS.pdf for a better documentation.

           

          Last edit: Eugenio Di Lorenzo 2017-05-29
  • Simon Sobisch

    Simon Sobisch - 2017-05-29

    Just tested, reattach would have fixed the screenshots. You only need to re-upload one now, it seems.

     
  • Eugenio Di Lorenzo

    Hi to all.
    I need your help to understand a strange behavior of the system.
    To explain the problem I attach two screenshots.
    The attached application (GC71CRUDECUD-2.cob) issues an error message because the first screen field is mandatory and has not been typed by the user. See first screenshot.
    The error message correctly appears on the screen the first time.
    Every time later (the user presses "enter" again without typing anything) the message appears only partially (see the second screenshot). This behavior is systematic.
    Each time the program emits the message the process is as follows:
    - save the whole screen with scr_dump (from the pdcurses library)
    - Sends the error message on the screen with the GC02BOXMEX program (cobol source is in contribution/trunk/tools/TUI-TOOLS)
    - restore screen with scr_restore (from pdcurses library)
    I'm breaking my head but I cannot understand the reason. There is something linked to pdcurses library I think. Any help highly appreciated.

    COMPILER INFO (built by A.trembley).
    cobc (GNU Cobol) 2.0.0
    Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
    Copyright (C) 2006-2012 Roger While
    Copyright (C) 2009,2010,2012,2014,2015 Simon Sobisch
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Built Feb 15 2016 00:20:46
    Packaged Oct 25 2015 21:40:28 UTC
    C version "4.8.1"

     

    Last edit: Eugenio Di Lorenzo 2017-05-29

Log in to post a comment.