Work File error

 5 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
Chesca
Veteran Member
Posts: 490
Veteran Member

    Hello, I have never wrote Lawson code to sort a file internally so I am using a Lawson program as model. My goal is to sort some records and then create a report. Any suggestions would be greatly appreciated.

    I created a WF and SF file in the work definition section. I am getting an error :  bad File Status 9 009 on file Work-File. Here is my source code: 

               PERFORM 900-BUILD-TMP-FILE-NAME.
               MOVE WS-TMP-FILE            TO WS-WORK-FILENAME.

               OPEN OUTPUT WORK-FILE.

    jaherb
    Veteran Member
    Posts: 164
    Veteran Member
      Are you modifying an existing program or are you starting from scratch?

      If you are starting from scratch, when you paint the program, instead of selecting an index, during the paint process, select f6, and create your own sort sequence.  The paint process will take care of setting up the internal sort.

      Chesca
      Veteran Member
      Posts: 490
      Veteran Member
        I am modifying an existing program so I sort of copied code from PR113 to build a temp file. So the issue is when trying to either build or open the work file.
        jaherb
        Veteran Member
        Posts: 164
        Veteran Member
          For a sort file, you do not need to create a "work" file but rather a "sort" file or "sequential" file. You do not need to use the 900-BUILD-TMP-FILE-NAME API.

          You need to populate the sort file fields and once populated you "release" the records. Once all the records are in the file, you then need to "return" the records in for processing.

          Your sort statement and input procedure (used to populate the fields) should look like this... In this example my sort had ascending and descending fields as you can see.

          SORT ZH720SORT-FILE
          ASCENDING KEY DSF-EMP-COMPANY
          DESCENDING KEY DSF-YOS
          ASCENDING KEY DSF-EMP-EMPLOYEE
          INPUT PROCEDURE 1000-SEL-REPORT
          OUTPUT PROCEDURE 1000-DO-REPORT.

          The 1000-SEL-REPORT section builds the data fields in the sort records and the the 1000-DO-REPORT, 'returns' the records after being sorted, to report on them in the desired sequence.

          The actual sort file definition looks like this....


          Work File Definition

          Product Line PROD File Record No
          System Code HR Sort File Yes
          Program Code ZH720 File Media Sequential
          File Name ZH720SORT Value/WsFld Id
          Prefix SF File Status

          Field Name Occurs Type Size 113

          EMP-COMPANY Numeric 4.0
          EMP-EMPLOYEE Numeric 9.0
          EMP-LAST-NAME-PRE AlphaLC 30
          EMP-NAME-SUFFIX AlphaLC 4
          EMP-LAST-NAME AlphaLC 30
          EMP-MIDDLE-INIT Alpha 1
          EMP-FIRST-NAME AlphaLC 15
          EMP-DEPARTMENT Alpha 5
          EMP-PROCESS-LEVEL Alpha 5
          EMP-ANNIVERS-DATE yyyymmdd 8
          YOS Numeric 2.0
          LauaLuau
          Basic Member
          Posts: 13
          Basic Member

            Did you ever figure this out?  I am getting same error with same code.

            LauaLuau
            Basic Member
            Posts: 13
            Basic Member

              I figured it out myself. After doing the bldsh, I no longer get the 09 009 on the work file open!

              You have to do the bldsh to bind the workdef.


                  Usage:  To build a COBOL program shell.
                  Syntax: bldsh [-FT123AO] ProductLine SystemCode ProgramCode
                              F - Force fListCols TRUE.
                              T - enable READY TRACE.
                              u - Build user exit program shell.
                              1 - Use 'c' bldrptpage Calls.
                              2 - [Default] Use 'COBOL' BLDRPTPAGE calls.
                                  Format Columns = 132
                              3 - Use 'COBOL' BLDRPTPAGE calls.
                                  Format Columns  = 66
                              A - Build COBOL program shell in Stage Directory.
                              O - Override Stage Compilation, compile runtime objects directly
               to Production