Variable line number SLNO(Y *VAR)

Hi All,

After all the years of programming I finally fond a reason to try the following with ther SLNO option in my DDS, but how to continue in RPGLE?

(every DDS record has (to try) 1 text and 1 Field (I/O) eg  Text-1: _______)
I will try to get the next thing working:

Eval  #SLN = 5
Write FMT01
Eval  #SLN = #SLN + 1
Write FMT02
Eval  #SLN = #SLN + 1
Write FMT03
Eval  #SLN = #SLN + 1


Text-1: _______
Text-2: ____0,00_
Text-3: _______________________

But on read only value of Text-3 is available (of course).
Is there anything I can do get this working?
(Subfile is no option)


LVL 17
Theo KouwenhovenApplication ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Murph

Are you still working on this?

I might have a sort of solution

Theo KouwenhovenApplication ConsultantAuthor Commented:
Hi Dave,

I'm not surprised that it's you again, I solved it more or less (a not so nice workaround) but please let me know the solution you found
I would use the
"QsnReadScr" & "QsnRtvDta" API's to read the input buffer.
This returns a 1920 byte field; calculate the position of the data in the string and sub string it out

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

API example to get the screen

 ** Create input buffe                                                
D CrtInpBuf       PR                  extproc( 'QsnCrtInpBuf')        
D   Len                         10I 0 Const                            
D   Inc                         10I 0 Const                            
D   Max                         10I 0 Const                            
D   Buffer                      10I 0                                  
D   Error                       10I 0 Const                            
 ** delete buffer                                                      
D DltBuf          PR                  extproc( 'QsnDltBuf')            
D   Buffer                      10I 0                                  
D   Error                       10I 0 Const                            
 ** Clear buffer                                                      
D ClrBuf          PR                  extproc( 'QsnClrBuf')            
D   Buffer                      10I 0 Const                            
D   ErrorCode                   10I 0 Const                            
** Read screen                                                          
 ReadScreen      PR                  extproc( 'QsnReadScr')              
   Length                      10I 0                                    
   Inp                         10I 0                                    
   CmdBuffer                   10I 0 Const                              
   Env                         10I 0 Const                              
   Error                       10I 0 Const                              
** Read immediate - alll input fields                                    
 RtvDta          PR                  extproc( 'QsnRtvDta')              
   Inp                         10I 0                                    
   Ptr                           *                                      
   Error                       10I 0 Const                              
 Env             S             10I 0                                    
 Inp             S             10I 0                                    
 Length          S             10I 0                                    
 Data            S           1920A   based(Ptr)                          
 C                   Callp     CrtInpBuf(1920 : 0 : 0 : Inp : 0 )                
 C                   Callp     ClrBuf(Inp : 0 )                                  
 C                   Callp     ReadScreen(Length : Inp : 0 : Env : 0 )          
 C                   Callp     RtvDta(Inp : Ptr : 0 )                            
 C                   Callp     DltBuf(Inp : 0 )                                  
 C                   Eval      *INLR = *on                                      



There is a function tha reads input fields but I am not sure if it only reds the active screen
Theo KouwenhovenApplication ConsultantAuthor Commented:
Hi Dave,

I will lok to this, but probably not for end of December...

Thanks till now.
If you want a greater level of control then I suggest you move to user defined data streams. It's a little tricky to get started but give absolute control of the display area. Let me know if you need more.
Theo KouwenhovenApplication ConsultantAuthor Commented:
Hi SuperCCA,

Yes I need more, that is (I hope) also the solusion to display fields with variable length!!

Let me know as much as possible.
You can do whatever you like but equally you have to do all display handling. First off you will need a copy of the 54594 Remote Control Unit Functions Reference manual SC30-3533-04. I know it sounds unlikely but this where the 5250 data stream is documented. If you get moving on this then I will try and post some 'get you started' code later.

Theo KouwenhovenApplication ConsultantAuthor Commented:
I found the following :
5494 Remote Control Unit
Functions Reference
Release 3.1
Document Number SC30-3533-04
Part Number 38H6893

This must be the one !!! If this is what I think it is.... I will put a new question for you with more points to earn.
I'm not fussed about points - I was on the site by accident and thought I'd help. Where would like the code posted?
Theo KouwenhovenApplication ConsultantAuthor Commented:
I don't know how much code it is....
you can copy and paste it to this site,
but if it is to much to paste please send it to

You will need the following DDS (note that FORMAT01 will not be used
but creates the necessary buffer space). Let's call it DSP5250

     A                                      DSPSIZ(24 80 *DS3)      
     A          R FORMAT01                  KEEP                    
     A            DATA       32763   H                                          
     A          R FORMATREC                 INVITE KEEP            
     A                                      PRINT                  
     A                                      USRDFN                  

ILERPG specifications

FDSP5250   CF   F32763        WORKSTN            
F                                     PASS(*NOIND)
D Hex             S              1    DIM(255)    
D                 DS                              
D  @Q                     1      4B 0            
D  @sHex                  3      4                
D                 DS                              
D  @X                     1      2  0            
D  @sX                    1      2                
D UsrDta          DS                              
D  @sPutLen               1      2B 0            
D  @sGetLen               3      4B 0            
D  @sFunction             5      5                          
D @pDS5250        DS                                    
D  Arr                    1  32758    DIM(32758)        
 * Work Fields                                          
D*@x              S              2  0                    
 * Internal Input Specifications                        
IDSP5250   NS                                            
I                                  132758  @pDS5250      
 * Build Hex Values Array                                
C     1             Do        255           @Q          
C                   Move      @sHex         Hex(@Q)      
C                   Enddo                                          
 * Build Data Stream                                                
C                   Eval      @pDS5250 =                            
 * Clear Display                                                    
C                             x'0440' +                            
 * Write to display                                                
C                             x'04112008' +                        
 * Screen Title (SBA,Att,Data,Att)                                  
C                             x'11012222' + 'Play with 5250' + x'20'
 * 10 lines of text and varying length fields                      
C                   For       @x = 5 to 14                          
C                   Eval      @pDS5250 = %Trim(@pDS5250) +          
 * SBA,Row,Column                                                  
C                             x'11' + Hex(@x) + x'05' +      
 * Data                                                      
C                             x'20' + 'Text ' + @sX + x'20' +
 * SBA,Row,Column                                            
C                             x'11' + Hex(@x) + x'14' +      
 * Start of field                                            
C                             x'1D40002400' + Hex(@x)        
C                   Endfor                                  
 * Set control data                                          
C     ' '           Checkr    @pDS5250      @sPutLen        
C                   Eval      @sGetLen = 300                
C                   Eval      @sFunction = x'73'            
 * Send to display                                          
C                   Except    DSPREC                      
C                   Read      DSP5250                      
 * End of program                                          
C                   Eval      *inlr = *on                  
 * Internal Output specifications                          
ODSP5250   E            DSPREC                            
O                                           K9 'FORMATREC'
O                       USRDTA               5            
O                       @pDS5250         32763            


(PS watch yourself if you introduce other 5250 orders, one mistake can crash your emulation session and under some circumstances no 5250 session will be usable until reboot.
Theo KouwenhovenApplication ConsultantAuthor Commented:
Hee SuperCCA,

This is really great, Can I do the same trick with Subfile programs????
The short answer is no.

You are now operating below OS/400 display management and ALL functionality must be provided by yourself.

The longer answer is yes.

If you take responsibility for the Page Up/Down AID keys then you can provide all the capabilities of a Sfl but you do need to work harder.

Also if you want to access the data keyed into the input fields you will need to put a Read MDT command on the end of the string - x'0442' from memory.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.