Perplexed by LAWSON

Sort:
You are not authorized to post a reply.
Author
Messages
Rita
Basic Member
Posts: 15
Basic Member
    As I stated before I am new to LAWSON and have a few questions. Please excuse me if they sound dumb.

    I see custom defined code which looks like this:

    MOVE EMP-LAST-NAME          TO HRWS-LAST-NAME.
    MOVE EMP-FIRST-NAME         TO HRWS-FIRST-NAME.
    MOVE EMP-MIDDLE-INIT        TO HRWS-MIDDLE-INIT.
    MOVE EMP-NAME-SUFFIX        TO HRWS-NAME-SUFFIX.
    MOVE EMP-LAST-NAME-PRE      TO HRWS-LAST-NAME-PRE.
    PERFORM 750-HR-FORMAT-NAME.
    MOVE HRWS-FORMAT-NAME       TO PR32F2-EMP-FULL-NAME

    as I painted my program I used LAWSON defined FULL-NAME and it generated very cumbersome (79 lines) code behind the scenes which does the same thing as the 7 lines of code I pasted on top. Is there a reason for this? What is the proper protocol should I be changing the auto generated code into readable? Or should I leave it alone?

    Thank you, Rita

    Kwane McNeal
    Veteran Member
    Posts: 479
    Veteran Member
      Rita,

      The 6th line is most likely what expanded to the 70+ additional lines. If you noticed, you didn't have to define the PERFORM routine. This is similar to using a standardized call in most modern languages, such as Java/C/C++.

      The preprocessor added the additional logic based on a template.



      The usual (simplified) flow of new programs is as follows:

      1) Paint the form

      2) Generate the resultant code

      3) Modify said program (this is where you can replace any inefficient code with functionally identical code)

      4) Compile and test completed program



      ...As for your question. I would at first leave the generated code alone to ensure your program works as intended, unless you need the optimized code to make the program work. After you pass initial testing, I would then strip the non-optimized code, replacing with the efficient code.



      I'm sure other more capable developers will chime in with more seasoned responses, but hopefully this helps the basic thought processes.



      Kwane



      jaherb
      Veteran Member
      Posts: 164
      Veteran Member
        Rita...

        When you paint the full name field, it generates a lot of code as you saw. You cannot alter what the paint process does. However I will always remove all of this code and use the code you supplied 750-HR-FORMAT-NAME. This routine is comes in the HR code and was generated well after the initial paint screen logic. I take the time to remove the "generated" code and use the above routine because it is so much of a smaller piece of code and easy to use. I have also used this routine to format CITY, STATE ZIP in the past as well

        This routine resides in a pdlib member called HRFN70CP.

        You have two options when using this routine... You can output HRWS-FORMAT-NAME or HRWS-FORMAT-FULL-NAME. The FORMAT-NAME option delivers your more typical naming convention, Lastname, Firstname MI. The FULL NAME option will deliver the names with all embedded spaces in each name field. As an example, the EMP-FIRST-NAME field is 15 spaces as defined int he db definition. If you took your name for an example, you would see; "RITA " (11 spaces) following it. on your report/extract. I will always use the FORMAT-NAME option to suppress the spaces out of the name fields.

        Good luck.

        Rita
        Basic Member
        Posts: 15
        Basic Member
          Besides the full name, there is a lot more crazy code that got generated. ie If statements without actions. Do I keep it for further reference, or could I just delete it?
          jaherb
          Veteran Member
          Posts: 164
          Veteran Member
            Rita... If you are going to use the 750-HR-FORMAT-NAME, you can remove all of the generated code from the paint pertaining to the name formatting. I have never noticed incomplete code in the routine however.

            Jim
            Rita
            Basic Member
            Posts: 15
            Basic Member
              Jim, the incomplete code I was talking about was not in the Full-Name routine, it was generated via other fields/buttons from the paint screen. I didn't know what to do with incomplete if/else statements so I just added move I1 to I1 line to get a successful compile, but it bothers me that this pointless code is there.

              What is the proper protocol? Can I remove these ifs or will it cause problems in the future when there are additional changes requested?
              jaherb
              Veteran Member
              Posts: 164
              Veteran Member
                Rita... Can you cut and paste a sample of that code here? I have never seen that before.
                Rita
                Basic Member
                Posts: 15
                Basic Member

                  008400     IF (XZ36F1-FC NOT = "I" AND "+" AND "-")
                  008500         GO TO 210-END.
                  008600
                  008700     IF (XZ36F1-FC = "I" OR "+")
                  008800         MOVE I1 TO I1.

                  009000     PERFORM 850-FIND-NLT-TRDSET1.
                  009100     IF (XZ36F1-FC = "-")
                  009200         PERFORM 870-FIND-PREV-TRDSET1.
                  009300
                  =================================================================================
                  046400                 OR     (TIMERECORD-NOTFOUND)
                  046500                 OR     (TRD-COMPANY  NOT = XZ36F1-TRD-COMPANY)
                  046600                 OR     (TRD-EMPLOYEE NOT = XZ36F1-TRD-EMPLOYEE)
                  046700                 OR     (TRD-TIME-SEQ NOT = XZ36F1-TRD-TIME-SEQ)
                  046800
                  046900             IF (TIMERECORD-NOTFOUND)
                  047000             OR (TRD-COMPANY   NOT = XZ36F1-TRD-COMPANY)
                  047100             OR (TRD-EMPLOYEE NOT = XZ36F1-TRD-EMPLOYEE)
                  047200             OR (TRD-TIME-SEQ NOT = XZ36F1-TRD-TIME-SEQ)
                  0                      MOVE I1 TO I1
                  047300             ELSE
                  047400                 MOVE I1 TO I1
                                     END-IF
                  047500         END-IF
                  047600         IF (TIMERECORD-NOTFOUND)
                  047700         OR (TRD-COMPANY  NOT = XZ36F1-TRD-COMPANY)
                  047800         OR (TRD-EMPLOYEE NOT = XZ36F1-TRD-EMPLOYEE)
                  047900         OR (TRD-TIME-SEQ NOT = XZ36F1-TRD-TIME-SEQ)
                  048000             MOVE CRT-INQ-COMPLETE    TO CRT-MESSAGE



                  Move I1 to I1 is my code to make it compile

                  jaherb
                  Veteran Member
                  Posts: 164
                  Veteran Member
                    Rita...

                    So this is a form that you painted? Can you explain to me what you were trying to do? I worked for Lawson for 15 years and never saw it do anything like this. Although the "paint" process isn't perfect, I've never seen it generate incomplete code as you are showing.
                    Rita
                    Basic Member
                    Posts: 15
                    Basic Member
                      I was given a project two weeks ago with very minimum instructions of how Lawson works. At that time, I took key fields from a primary file, placed them on a screen as input with labels and output field name (if available) next to it with description such as full_name.

                      Then I added a few random fields from the primary file as input, added labels, came out and ran bldpgm and qcompile commands. My compile didn't work because of the incomplete code. I went back in via led command and added the move lines, it recompiled and worked.

                      Now I am working on figuring out how to display pay-period start and end dates (and get a drill screen for date selection), and after that it will be on how to display all the period dates within the range on the detail line.
                      Jason Beard
                      Veteran Member
                      Posts: 124
                      Veteran Member
                        Per Kwane's initial statement, the "Best Practice" if you are using the paint function is to paint the key portion of what you are trying to do and then edit as necessary. Someone else also correctly stated, once you edit the generated code, you cannot go back and re-generate or you will lose your modifications.
                        Is the compiler truly generating incomplete code? Looking at the line numbers it looks like there are some pieces missing in your paste.

                        To sum up, you can edit/remove/modify to your hearts content as long as you are not going to try and re-paint/re-gen code. Please let us know if you have any specific questions on making your form work as desired.

                        thank you
                        Jason Beard
                        617-548-5568
                        jabeard3@gmail.com
                        You are not authorized to post a reply.