View Full Version : Ermitteln der Satznummer in Subfile
peter.kinne
23-03-04, 06:56
Hallo zusammen,
ich habe ein kleines Problem mit einer Subfile, bei dem ich nach einer Lösung suche.
Ich habe eine Subfile die ein Eingabefeld enthält. Hinter diesem Feld gibt es ein Programm für die Bedienerführung, das man mit F4 (*INKD) aufrufen kann.
Wie komme ich an die Information, auf welchem Subfilesatz der Anwender die F4 gedrückt hat. Denn ich muss ja den selektierten Wert in das richtige Feld schreiben.
Das Feld SFLCRS(*CURSOR) hat zu diesem Zeitpunkt den Wert "1", und der Satz auf dem ich F4 gedrückt habe ist "5".
Vielen Dank für Eure Tipps,
Peter
RobertMack
23-03-04, 07:53
Hallo Peter,
lies mal im DDS-Handbuch das Schlüsselwort SFLRCDNBR nach:
R SFLCTL: RCDNR 4S 0H SFLRCDNBR
R SFLDTA: RCDNR 4S 0H
Viel Erfolg,
Robert
peter.kinne
23-03-04, 11:53
Hallo Robert,
das Schlüsselwort habe ich natürlich imt CTL angegeben.
Aber trotzdem gekomme ich bei F4 nicht die aktuelle Zeile in diesem Feld übermittelt.
Peter
tfroehlich
23-03-04, 12:05
Guten Tag,
ich habe zwar keine Ahnung, wie das mit F4(Hilfetext) funktioniert, aber mit READC(RPG III) müsste man doch
den Datensatz(mit den Bildschirmfeldern) doch
verarbeiten können.
Haltet mich auf den Laufenden. ich lerne gerne hinzu.
(demnächst RPG IV und ILE-RPG)
Gruss Thomas
Hallo Peter,
vielleicht hilft Dir diese Beispiel weiter:
Subfile Positioning
Hey, Ted:
I have several RPG IV programs that display a subfile in a work-with-like display. Users enter option numbers in the option field that begins each subfile record. When a user selects a subfile record, the system usually displays another display format in order to handle the request. When the subfile is redisplayed, the first page of the subfile is shown. How can I position the subfile to the page that contains the selected subfile record?
-- Patrick
You need to add the Subfile Record Number (SFLRCDNBR) keyword to your display files. Use this keyword with a four-digit, hidden, zoned-decimal field. The value in this field tells the system which page of a subfile to display. Update this field every time an option is processed. Initialize this field to the number one (1) every time you reload the subfile in order to avoid a run-time error. I recommend you use the CURSOR option to position to the record whose relative record number matches the value in the hidden field.
Here is a short RPG IV program and display file you can play with in order to understand this technique. When you run this program, use option 5 to display more information about a record. (Don’t worry--you don't need a database file; the program displays some dummy data.) When the subfile is redisplayed, you will see the page containing the last selected subfile record.
Here is display file CD1102D:
* To compile:
* CRTDSPF FILE(xxx/CD1102D) +
* SRCFILE(xxx/QDDSSRC) SRCMBR(CD1102D)
A CF03(03)
A DSPSIZ(24 80 *DS3)
A R SFL SFL
A OPT 1 B 6 3
A DTA 5 0O 6 8
A R CTL SFLCTL(SFL)
A SFLDSP
A SFLDSPCTL
A SFLSIZ(16)
A SFLPAG(15)
A POSRRN 4S 0H SFLRCDNBR(CURSOR)
A 5 3'Opt Data '
A DSPATR(UL)
A R SCRN
A NUM 5 0B 4 5
A ALPHA 28 O 4 15
Here is RPG program CD1102R:
* To compile
* CRTBNDRPG PGM(xxx/CD1102R) +
* SRCFILE(xxx/QRPGLESRC) SRCMBR(CD1102R)
Fcd1102d cf e workstn sfile(sfl:rrn)
D rrn s 4 0
D c c 'ABCDEFGHIJKLMNOPQRSTUVWXYZ7890-
D 1234567890abcde'
* fill the subfile with dummy data
C for rrn = 1 to 45
C eval dta = rrn
C write sfl
C endfor
* display the subfile
C eval posrrn = 1
C exfmt ctl
C dow not *in03
C exsr dosfl
C exfmt ctl
C enddo
C*
C eval *inlr = *on
* process subfile options
C dosfl begsr
C readc sfl
C dow not %eof(cd1102d)
C if opt = '5'
C exsr show
C z-add rrn posrrn
C eval opt = *blank
C update sfl
C endif
C readc sfl
C enddo
C endsr
* display the data
C show begsr
C*
C eval num = dta
C eval alpha = %char(num) + '='
C + %subst(c:num:1)
C exfmt scrn
C*
C endsr
-- Ted
Hallo Peter.
Ich habe früher (es ist schon etwas her) immer mit Auswahlfeldern (hier z.B. SAUSW) gearbeitet:
Mit F4 habe ich z.B. immer nur im ganzen Bildschirm gearbeitet.
Auslesen angezeigte angezeigte-SUBFILE-Sätze
*IN95 DOUEQ *ON
READC ..... BS1= Satzformat = SFL-Satz von Bildschirmdatei *IN95
*IN95 IFEQ *OFF
-----------------------------------------------------------------
SAUSW IFEQ '1' (Auswahl-Feld BS1) =======> Auswahlfeld (1)
Aktionen ... (= wie von Tarasik)
MOVE *ON *IN95
MOVE ' ' SAUSW
ENDIF
-----------------------------------------------------------------
Anstatt SAUSW-Eingabe/Abfrage (1)
-- Überlegung Cursor F4 -Ermittlung (2)
-----------------------------------------------------------------
Überlegung - wenn Cursor-Position innerhalb Gesamtbildschirm ermittelbar
z.B. von Zeile 9 - 21 = Subfile-Satz-Anzeige
Cursor steht auf Zeile 13: 13 - 8 = 5
= 5-ter angezeigter Subfile-Satz
=======> Cursor (2)
SRSNR IFEQ 5 (SRSNR = Zähler lfd.Satz Nr. pro Subfile-Seite)
= verdecktes H(hidden) Feld im Satzformat BS1)
Aktionen ....
MOVE *ON *IN95
ENDIF
-----------------------------------------------------------------
ENDIF
ENDDO
==========================================
Viele Grüsse Alf
RobertMack
23-03-04, 16:09
Peter,
das Schlüsselwort im CTLFMT genügt nicht, das im Schlüsselwort definierte Feld RCDNR muss im Subfile als Hidden Field ergänzt werden ...
Gruß, Robert
Hallo Peter,
ich glaube hier werden 2 Sachen vertauscht. Das Schlüsselwort SFLRCDNBR wird benötigt, wenn Du den Cursor nach der Verarbeitung wieder auf einem bestimmten Subfilesatz positionieren willst.
Du willst aber wissen auf welchem Subfilesatz die F4 gedrückt wurde. Dafür brauchst Du das Schlüsselwort SFLCSRRRN beim Controlsatz. In diese Variable wird der Wert geschrieben.
Gruß,
KM
Hallo Peter,
da hat KM recht und ich habe noch etwas dazu gefunden:
Select Subfile Records by Position
Hey, Ted:
We have inquiry programs that require users to key an X next to a subfile record in order to select the record. I have seen programs that require that a user place the cursor on a subfile record and press Enter to select it. If we could use that technique, it would mean less keying for the users. Can you tell me how to select a subfile record by cursor position?
--Chad
This is not a difficult technique to use, and, yes, it will help the users by requiring them to key less.
In the display file, define a hidden five-digit zoned decimal field and assign it to the SFLCSRRRN keyword, like this:
A SFLCSRRRN(&S1SLTRRN)
A S1SLTRRN 5S 0H
The relative record number of the selected record will be returned through the hidden field. If the cursor is not sitting on a subfile record, the hidden field will have a value of zero.
Here is a short display file and an RPG program you can play with to learn about this technique. It builds a small subfile of five records. When you call the program, move the cursor to one of the subfile records or outside of the subfile. When you press Enter, the system will tell you the number of the record you selected and retrieve the data from the record.
* display file SFL333D
A DSPSIZ(24 80 *DS3)
A INDARA
A CA03(03 'F3=EXIT')
A CA12(12 'F12=CANCEL')
A R S1SFL SFL
A S1DATA 40 O 5 2
A R S1CTL SFLCTL(S1SFL)
A SFLSIZ(13)
A SFLPAG(11)
A OVERLAY
A SFLCSRRRN(&S1SLTRRN)
A 45 SFLDSP
A 44 SFLDSPCTL
A N99 SFLEND(*MORE)
A S1SFLRRN 4S 0H
A S1SLTRRN 5S 0H
A 2 2'Selected record:'
A CTLRCD 3 0O 2 19EDTCDE(1)
A 2 25'Data:'
A CTLDATA 40 O 2 31
A 4 2'Move cursor, press Enter.'
A DSPATR(UL)
A R S1LEGEND
A 17 2'F3=Exit F12=Cancel'
* RPG program SFL333R
H option(*srcstmt: *nodebugio)
H dftactgrp(*no) actgrp(*new)
Fsfl333d cf e workstn
F indds(wsIndicators)
F sfile(s1SFL:s1SFLRRN)
D CancelRequestd s n
* Indicator data structure for display file
D wsIndicators DS 99
D wsExit 3 3N
D wsCancel 12 12N
D s1SflDspCtl 44 44N
D s1SflDsp 45 45N
D msgSFLEnd 99 99n inz('0')
* load the subfile
C exsr s1LoadSFL
* until user cancels
C dou CancelRequestd
* display the subfile
C write s1Legend
C exfmt s1Ctl
C if wsCancel or wsExit
C eval CancelRequestd = *
C iter
C endif
* select the record the cursor is sitting on
C eval ctlRcd = s1SltRRN
C if s1SltRRN > *zero
C s1SltRRN chain s1SFL
C eval ctlData = s1Data
C else
C eval ctlData = '*NONE*'
C endif
C enddo
C
C eval *inlr = *on
* ================================================== ========
C s1LoadSFL begsr
C
C eval s1Data = 'The first record.'
C eval s1SFLRRN = 1
C write s1SFL
C eval s1Data = 'Another record.'
C eval s1SFLRRN = 2
C write s1SFL
C eval s1Data = 'Yet another record.'
C eval s1SFLRRN = 3
C write s1SFL
C eval s1Data = 'Record 4.'
C eval s1SFLRRN = 4
C write s1SFL
C eval s1Data = 'The last record.'
C eval s1SFLRRN = 5
C write s1SFL
C
C eval s1SflDspCtl = *on
C eval s1SflDsp = *on
C
C endsr
peter.kinne
24-03-04, 07:18
Hallo an Alle,
vielen Dank für die vielen Tipps.
Ich habe mich für die Variante "SFLCSRRRN" entschieden. Die bringt genaus das Ergebnis, dass ich brauche.
Schönen Tag noch,
Peter