ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Help need to develop my fist program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help need to develop my fist program

    Hi All,

    First of all i must say that i am a new to AS 400 RPGLE, and use free formatting.

    So may office handover to me to design a Display with the option for enter the these customer number (which a filed in PF file), and when i enter the values and press enter then a report must generate which should be contain all the data corresponding the input value.


    So i manage to do this

    01. I design the display
    02. Able to validate the user input (Such as not enter blanks/should be valid one)
    03. I also manage to design externally describe prtf file

    But the issue is when i press enter it only print one record only, then i use dou loop but then program goes into high CPU vale and stack

    So tel me how i do this

    Any sample program would be great

    Thanks

  • #2
    Re: Help need to develop my fist program

    I think debug is your friend here. You need to use a debug tool, STRDBG on green screen or service entry point with wdsc. Your RPGLE program should be compiled with DBGVIEW *SOURCE.
    Then step through your code to fully understand where the logic goes before and after printing the one record. It is likely looping without some kind of increment, or checking for end condition. Debug will give you the control and especially as you are new to the language it gives a major insight to your program.
    the smoking gnu

    Comment


    • #3
      Re: Help need to develop my fist program

      Hey Skippy --- You show us yours and we will show you ours!

      Post the code you have now so we can all take a peek.
      I'm here to chew bubble gum and kick @#%@#%@#%.....and I'm all outta bubble gum !
      Yes I'm talking to you squirrel nuts.

      Comment


      • #4
        Re: Help need to develop my fist program

        Hei all,

        I try using debug mode but my Dow loop is not working correctly ,it end after read the file in second time and the it begins

        Here all the details (don't worry with the report file design because i did not complete it,please check other)


        RPGLE main Pgm

        Code:
        0001.00 FLNP00301LFUF A E           K DISK                                                                  120623
        0002.00 FMAINMEMU  CF   E             WORKSTN indds(indicators)                                             120623
        0002.01 FMAINPRTF  O    E             PRINTER oflind(*in10)                                                 120627
        0003.00 Dindicators       ds                                                                                120623
        0004.00 DexitKey                          n   overlay(indicators:3)                                         120625
        0006.00 DgenerateKey                      n   overlay(indicators:6)                                         120625
        0006.01 DrecordFound                      n                                                                 120625
        0008.00 DinstNotFound                     n   overlay(indicators:52)                                        120625
        0008.01 DinstEmpty                        n   overlay(indicators:51)                                        120625
        0008.02 Dinst                             n   overlay(indicators:50)                                        120627
        0009.00 C     CSTKEY        KLIST                                                                           120623
        0010.00 C                   KFLD                    LNUSR3                                                  120627
        0011.00  /free                                                                                              120623
        0012.00       exfmt hdrscn;                                                                                 120625
        0013.00       // Loop until exit key is pressed                                                             120625
        0014.00       dow not exitKey;                                                                              120625
        0014.01       if LNUSR3 <> '';                                                                              120627
        0014.02       instEmpty = *OFF;                                                                             120625
        0015.00       exsr GenerateSub;                                                                             120625
        0015.03       endif;                                                                                        120625
        0015.04       if exitKey;                                                                                   120625
        0015.05       leave;                                                                                        120625
        0015.06       endif;                                                                                        120625
        0015.07       exfmt hdrscn;                                                                                 120625
        0018.01       // turn off error messages                                                                    120625
        0018.02       instNotFound = *off;                                                                          120625
        0018.03       enddo;                                                                                        120625
        0019.00       *inlr = *on;                                                                                  120625
        0020.11       //****************************************************************                            120625
        0020.12       // SUBROUTINE -GenerateSub *                                                                  120625 
        0021.00       // PURPOSE - Display Printing is OK *                                                         120625 
        0022.00       //****************************************************************                            120625 
        0023.00       begsr GenerateSub;                                                                            120625 
        0023.01       // Lookup Institute Code                                                                      120625 
        0024.00       chain CSTKEY LNP0031; // don't lock record                                                    120625 
        0025.00       if not %found(LNP00301LF);                                                                    120625 
        0025.01       // Institute Code is not found in file                                                        120625 
        0026.00       instNotFound = *on;                                                                           120625 
        0027.00       leavesr;                                                                                      120625 
        0030.09       endif;                                                                                        120626
        0030.10       write head;                                                                                   120627
        0030.11       setll cstkey LNP0031;                                                                         120627
        0030.12       read LNP0031;                                                                                 120627
        [B]0030.19       dow not %eof(LNP00301LF);                                                                     120627
        0030.20       if *in10 =*on;                                                                                120627
        0030.21       write head;                                                                                   120627
        0030.22       *in10 = *off;                                                                                 120627
        0030.23       else;                                                                                         120627
        0030.25       write DETAILS;                                                                                120627
        0030.26       read LNP0031;                                                                                 120627
        0030.27       endif;                                                                                        120627
        0030.32       enddo;                                                                                        120626[/B]
        0030.34       exfmt CSTINQ;                                                                                 120626
        0031.00       endsr; // end of subroutine GenerateSub;                                                      120625
        0032.00  /end-free                                                                                          120625
                ****************** End of data ***************************************************************************
        Display File

        Code:
        		0000.10      A*%%TS  SD  20120625  224143  SDBL1450    REL-V6R1M0  5761-WDS                                      120625
        0000.20      A*%%EC                                                                                              120625
        0000.30      A                                      DSPSIZ(24 80 *DS3)                                           120625
        0000.40      A                                      REF(*LIBL/LNP00301LF)                                        120625
        0000.50      A                                      CHGINPDFT(CS)                                                120625
        0000.60      A                                      CA03(03 'EXIT')                                              120625
        0000.70      A                                      PRINT(*LIBL/QSYSPRT)                                         120625
        0000.80      A                                      INDARA                                                       120625
        0000.90      A          R HDRSCN                                                                                 120625
        0001.00      A*%%TS  SD  20120625  223602  SDBL1450    REL-V6R1M0  5761-WDS                                      120625
        0001.10      A                                      OVERLAY                                                      120625
        0001.20      A                                  2  4TIME                                                         120625
        0001.30      A                                  2 29'DATA INQUIRE MENU'                                          120625
        0001.40      A                                  2 70DATE                                                         120625
        0001.50      A                                      EDTCDE(Y)                                                    120625
        0001.60      A            LNUSR3    R     A  I  8 40REFFLD(LNUSR3)                                               120625
        0001.70      A                                      DSPATR(UL)                                                   120625
        0001.80      A                                      COLOR(PNK)                                                   120625
        0001.90      A                                      CHECK(ME)                                                    120625
        0002.00      A  52                                  ERRMSG('Istitute code not in the fi-                         120625
        0002.10      A                                      le' 52)                                                      120625
        0002.20      A N51                                  ERRMSG('Filed cannnot empty' 51)                             120625
        0002.30      A                                  6 10'ENTER VALID INSTITUTE CODE'                                 120625
        0002.40      A                                  8 17'ENTER INSTITUTE CODE:'                                      120625
        0002.50      A                                 21  5'PRESS ENTER TO GENERATE REPORT'                             120625
        0002.60      A                                 23  5'F3 - EXIT'                                                  120625
        0002.70      A          R CSTINQ                                                                                 120625
        0002.80      A                                      CA12(12 'CANCEL')                                            120625
        0002.90      A                                      OVERLAY                                                      120620
        0003.00      A                                 11 25'REPORT SUCEEFULLY GENERATED'                                120623
        0003.10      A                                      COLOR(RED)                                                   120623
        0003.50      A                                 23 20'F12 - CANCEL'                                               120625
        0003.60      A                                 23  5'F3 - EXIT'                                                  120625
                ****************** End of data ********************************************************************************
        Logical File

        Code:
        		0001.00 A*****************************************************************                                       120623
        0001.01 A********FILE NAME: LNP00301LF************************************                                       120623
        0001.02 A********DESCRIPTION: THIS IS LOGICAL FILE LNP00301LF*************                                       120623
        0007.00 A*****************************************************************                                       120623
        0008.00 A               R LNP0031                   PFILE(MAY25DTF/LNP00301)                                     120623
        0008.01 A                 LNUSR3                                                                                 120625
        0009.00 A                 LNNOTE                                                                                 120623
        0010.00 A                 LNSHRT                                                                                 120623
        0011.00 A                 LNBRCH                                                                                 120623
        0011.01 A                 LNTYPE                                                                                 120623
        0011.02 A                 LNNONF                                                                                 120623
        0011.05 A                 LNFACE                                                                                 120623
        0011.06 A                 LNDISB                                                                                 120623
        0011.07 A                 LNBAL                                                                                  120623
        0011.08 A                 LNPMPS                                                                                 120623
        0011.09 A                 LNPDLS                                                                                 120623
        0011.10 A                 LNCLSF                                                                                 120623
        0011.11 A                 LNSTAT                                                                                 120623
        0012.00 A               K LNUSR3                                                                                 120627
        Printer File

        Code:
                *************** Beginning of data *****************************************************************************
        0001.00 A                                           REF(MAY25DTF/LNP00301)                                       120626
        0002.00 A               R HEAD                      SPACEA(2)                                                    120627
        0003.00 A                                           SKIPB(001)                                                   120626
        0004.00 A                                           TEXT('ISNTITUTE CODE FORMAT')                                120626
        0005.00 A                                           FONT(222)                                                    120626
        0006.00 A                                         55'DATA INQUERY REPORT'                                        120626
        0007.00 A                                          5DATE EDTCDE(Y)                                               120626
        0007.01 A                                           SPACEA(2)                                                    120627
        0010.00 A                                          1'NOTE NUMBER'                                                120627
        0010.01 A                                         13'SHORT NAME'                                                 120627
        0010.02 A                                         31'BRANCH NUMBER'                                              120627
        0010.03 A                                         44'LOAN TYPE'                                                  120627
        0010.04 A                                         53'NON-ACCRUAL FLAG'                                           120627
        0010.05 A                                         69'FACE AMOUNT OF NOTE'                                        120627
        0010.06 A                                         88'TOTAL AMT DISBURSED'                                        120627
        0010.07 A                                        101'CURRENT'                                                    120627
        0010.08 A                                        106'TOTAL'                                                      120627
        0010.09 A                                        111'DAYS'                                                       120627
        0010.10 A                                        115'CLASS'                                                      120627
        0010.11 A                                        125'LOAN STATUS'                                                120627
        0010.12 A                                           SPACEA(2)                                                    120627
        0010.13 A               R DETAILS                                                                                120626
        0011.00 A                 LNNOTE    R              1                                                             120627
        0012.00 A                 LNSHRT    R             12                                                             120627
        0013.00 A                 LNBRCH    R             22                                                             120627
        0014.00 A                 LNTYPE    R             35                                                             120627
        0015.00 A                 LNNONF    R             44                                                             120627
        0016.00 A                 LNFACE    R             60                                                             120627
        0017.00 A                 LNDISB    R             79                                                             120627
        0018.00 A                 LNBAL     R             98                                                             120627 
        0019.00 A                 LNPMPS    R        O   123                                                             120627 
        0020.00 A                 LNPDLS    R        O   149                                                             120627 
        0021.00 A                 LNCLSF    R        O   174                                                             120627 
        0022.00 A                 LNSTAT    R        O   185                                                             120627 
                ****************** End of data *********************************************************************************

        Comment


        • #5
          Re: Help need to develop my fist program

          you need to move your read from the IF statement!
          Code:
          0030.20       if *in10 =*on;                                                                                120627
          0030.21       write head;                                                                                   120627
          0030.22       *in10 = *off;                                                                                 120627
          0030.23       else;                                                                                         120627
          0030.25       write DETAILS;                                                                                120627
          [COLOR="#FF0000"]0030.26       read LNP0031;                                                                                 120627[/COLOR]
          0030.27       endif;
          move the line in red below the endif. you are only reading the file when overflow occurs
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: Help need to develop my fist program

            Hello,
            I did that but when i did that it only print one line of the file, but my pf contain lots of data, that is way i told you my Dow loop only runs one time, then it not working. I want to print all the data regarding what i input in the display



            See the out put



            Code:
            File  . . . . . :   MAINPRTF                                                                             Page/Line   1/1           
            Control . . . . .                                                                                        Columns     1 - 130       
            Find  . . . . . .                                                                                                                  
            *...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3 
                27/06/12                                          DATA INQUERY REPORT                                                          
            NOTE NUMBER SHORT NAME        BRANCH NUMBERLOAN TYPENON-ACCRUAL FLAGFACE AMOUNT OF NOTETOTAL AMT DISCURRETOTALDAYSCLASS     LOAN S 
                   1869FEDERATION O1 TCCS     106                      0004400000000      0004400000000      0000000000000            00000000

            Comment


            • #7
              Re: Help need to develop my fist program

              is it possible you are hitting a copy of the file higher in your library list other than the one you are actually wanting to read?
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Help need to develop my fist program

                Dear sir,

                No i am directly refer this file(LNP00301) locates at here using LF MAY25DTF/LNP00301

                Here the output of the actual file,and i am input user filed 3 value for ex:001A00

                Code:
                                                                         Display Report                                                            
                                                                                                                 Report width . . . . . :     178  
                Position to line  . . . . .                                                                  Shift to column  . . . . . .          
                Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10....+...11....+...12....
                       User               Note    Short               Branch  Loan  Non-Accrual             Face             Total               Cu
                       Field              Number  Name                Number  Type  Flag                    Amount           Amt                 Pr
                       3                                                                                    Of               Disbursed           Ba
                000001                       392  @@@@@@@                 42    101                          850.00              850.00             
                000002                       393  $$$$$$$$$$              42    101                      246,000.00          246,000.00             
                000003                       394  ^^^^^^^^                 42    101                       85,000.00           85,000.00             
                000004                       395  &&&&&&&&&                 42    101                       85,000.00           85,000.00             
                000005                       396  XXXXXXXXXX                 42    101                       85,000.00                 .00

                Comment


                • #9
                  Re: Help need to develop my fist program

                  are you sure it's not simply overlaying the first record repeatedly? in your printer file you don't have any SPACEA() or SPACEB() on the DETAIL definitions:
                  Code:
                  [COLOR="#FF0000"]0010.12 A                                           SPACEA(2)                                                    120627[/COLOR]
                  0010.13 A               R DETAILS                                                                                120626
                  0011.00 A                 LNNOTE    R              1                                                             120627
                  0012.00 A                 LNSHRT    R             12                                                             120627
                  0013.00 A                 LNBRCH    R             22                                                             120627
                  0014.00 A                 LNTYPE    R             35                                                             120627
                  0015.00 A                 LNNONF    R             44                                                             120627
                  0016.00 A                 LNFACE    R             60                                                             120627
                  0017.00 A                 LNDISB    R             79
                  note that you have the SPACEA prior to the record format keyword which means that is actually a part of the HEAD record format. did you run this in debug and observe that the loop is only reading once or are you assuming that is the case? (not slamming you just trying to figure out what's going on here.)
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: Help need to develop my fist program

                    Hi chorauoc:

                    This:
                    Code:
                    [B]0030.20       if *in10 =*on;                                                                                
                    0030.21       write head;                                                                                   
                    0030.22       *in10 = *off;                                                                                
                    0030.23       else;                                                                                        
                    0030.25       write DETAILS;                                                                                
                    0030.26       read LNP0031;                                                                                 
                    0030.27       endif;         
                    [/B]
                    Should be this:
                    Code:
                    [B]0030.20       if *in10 =*on;                                                                               
                    0030.21       write head;                                                                                   
                    0030.22       *in10 = *off;                                                                                 
                    0030.23       endif;                                                                                         
                    0030.25       write DETAILS;                                                                                
                    0030.26       read LNP0031;                                                                                        [/B]
                    Best of luck
                    GLS

                    < edit > just saw tom already caught this one < / edit >
                    Last edited by GLS400; June 27, 2012, 10:54 AM.
                    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                    Comment


                    • #11
                      Re: Help need to develop my fist program

                      Thanks corrected, now working fine.

                      Thanks for help

                      Love this site

                      Comment

                      Working...
                      X