Você está na página 1de 10

String Handling

Day 7
Overview:
This module enables the student to understand various String Functions.
Outline:
Topics covered,
IPN
String Handling pcodes.
Objective:
!y the end o" this module, the student should be able to#
IPN
$nderstand the various String Handling pcodes li%e & MOVE, MOVEL, CAT,
S!ST, SCAN, CHEC", CHE"# and $LATE%
' Du%eStar Technologies Pvt. (td.
)*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
String Handling
Day 7
First ,e ,ill study the IPN speci-cation
IPN:
IPN is used to de-ne the constant values. IPN Speci-cation line is bro%en into
"ollo,ing parts.
P&'iti&n' Na(e Entr)
)./ !lan%
0 Form type I
7.1+ !lan%
1).21 3onstant 3onstant 4alue
25 Data Type c, !lan%
22./1 !lan%
/5./6 3onstant Name Name
/7.72 !lan%
C&n'tant: 8rite the constant 4alues in this position.
*ata T)+e: 8rite here 93:. 3 stands "or constant.
,ield Na(e: 8rite the name o" the -eld, ,hich hold the constant values.
Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXA7
FM ! ..... !. 1 ..."... # ..."... $ ..."... % ..."... & ..."... ' ..."... 7
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 !,EF-.-.G C/.SA. US-.G -P. PR/MP
000#.00 - 01E2C/ME / ,U3ESAR0 C F2,1
000$.00 C F2,1 ,SP2Y
000%.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!






P4om5t t65( . . . . S(7u(n8( num9(4 . . . 000#.00

,+t+ Fi(ld
Const+nt 65( .+m(
01E2C/ME / ,U3ESAR0 C F2,1

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s

>C? C/PYR-G@ -BM C/RP. 1AB1C #00#.
' Du%eStar Technologies Pvt. (td.
1*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
String Handling
Day 7
MOVE -M&ve #ig.t t& Le/t0
;oves the character*numeric -eld in Factor1 to character*numeric -eld in <esult "rom
right to le"t.

Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXAB
FM ! ..... !. 1 ..."... # ..."... $ ..."... % ..."... & ..."... ' ..."... 7
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0000.01 !,(*in( + 8onst+nt +nd ,is5l+6 it.
0001.00 - 01E2C/ME / 0 C F2,1
000#.00 C F2,1 ,SP2Y
000#.01 !,(*in( + 8;+4+8t(4 <+4i+9l(.
000#.0# C M/DE !B2A.3S F2,# B
000#.0$ !Mo<( st4in) to + <+4i+9l( +nd ,is5l+6 it.
000$.00 C M/DE 0,U3ESAR0F2,#
000%.00 C F2,# ,SP2Y
000%.01 !,(*in( + .um(4i8 <+4i+9l(.
000&.00 C EFA,,1#$%.&' F2,$ '#
000&.01 !Cl(+4 t;( C;+4+8t(4 <+4i+9l(.
000&.0# C M/DE !B2A.3S F2,#
000&.0$ !Mo<( num(4i8 <+lu( to C;+4+8t(4 <+4i+9l(
000'.00 C M/DE F2,$ F2,#
0007.00 C F2,# ,SP2Y
000B.00 C SE/. 2R

!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
F$=E:it F%=P4om5t F&=R(*4(s; FA=R(t4i(<( F10=Cu4so4 F11=o))l(
F1'=R(5(+t *ind F17=R(5(+t 8;+n)( F#%=Mo4( =(6s
' Du%eStar Technologies Pvt. (td.
5*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1
,act&r 2 Source 3haracter*Numeric
#e'ult
,ield
Target 3haracter*Numeric
HI
LO
E3
String Handling
Day 7
MOVEL -M&ve Le/t t& #ig.t0
;oves the character*numeric -eld in Factor1 to character*numeric -eld in <esult "rom le"t
to right.

Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXAA
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE20,U3ESAR0F2,1 %
000#.00 C F2,1 ,SP2Y
000$.00 C M/DE 0,U3ESAR0F2,# %
000%.00 C F2,# ,SP2Y
000&.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



P4om5t t65( . . . C S(7u(n8( num9(4 . . . 0001.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
M/DE2 0,U3ESAR0 F2,1
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
%

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s

' Du%eStar Technologies Pvt. (td.
2*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1
,act&r 2 Source 3haracter*Numeric
#e'ult
,ield
Target 3haracter*Numeric
HI
LO
E3
String Handling
Day 7
CAT-C&ncatenate tw& c.aracter 'tring'0
The 3=T opcode is use"ul "or combining the values o" t,o strings to "orm a third string.
The t,o character data items to be combined are speci-ed in "actor ) and "actor1.
The result -eld entry speci-es ,here the results o" concatenation are to be placed.
>ou can also speci"y the number o" blan%s bet,een the non.blan% characters o" the
combined -elds by appending a ?#@ to the "actor 1 item "ollo,ed by an integer literal,
-eld etc. $se P in H*N*P entry to indicate that result -eld should be padded ,ith
blan%s a"ter concatenation. No indicators are used ,ith the 3=T opcode.

Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXA10
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE 0,U3E0 F2,1 %
000#.00 C M/DE 0SAR0 F2,# %
000$.00 !C/.CAE.A-.G F2,1 +nd F2,#
000%.00 C F2,1 CA F2,# RES 10
000&.00 C RES ,SP2Y
000'.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000%.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
F2,1 CA F2,# RES
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
10

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s

' Du%eStar Technologies Pvt. (td.
/*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 Source String )
?;andatory@
,act&r 2 Source String 1
?;andatory@
#e'ult
,ield
<esult String
?;andatory@
HI
LO
E3
String Handling
Day 7
S!ST -Sub'tring0
The S$!ST opcode eAtracts a portion o" a character string into a diBerent -eld. Factor )
reCuired "or this operation, represents the length o" the string to be copied. Factor1 is
also reCuired, contains the based character string or base character string "ollo,ed by
colon "ollo,ed by starting position. The result -eld serves as the receiving -eld "or the
S$!ST operation. =n optional indicator in position /0./7 ?(@ comes on i" an error during
the S$!ST operation.
Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXA11
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE 0,U3ESAR0F2,1 B
000#.00 !SUBSR-.G F2,1 FR/M F-RS P/S--/. A., F/UR C@ARACERS
000$.00 C % SUBSF2,1:1 RES1 %
000%.00 C RES1 ,SP2Y
000%.01 !SUBSR-.G F2,1 FR/M F-F@ P/S--/. A., F/UR C@ARACERS
000&.00 C % SUBSF2,1:& RES# %
000'.00 C RES# ,SP2Y
0007.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000$.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
% SUBS F2,1:1 RES1
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
%

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( %eys

' Du%eStar Technologies Pvt. (td.
0*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 (ength to eAtract "rom !ase String
?;andatory@
Numeric
,act&r 2 !ase String# ?;andatory@
#e'ult ,ield <esult String ?;andatory@
HI
LO D< ?ptional@
E3
String Handling
Day 7
SCAN -Scan C.aracter String0
SCAN operation allo,s us to loo% "or a character or string o" characters ,ithin a
character -eld. The direction is "rom le"t to right. Scan is case sensitive.
Factor) contains string to be searched called as compare string.
Factor1 contains string to be scanned called as base string.
<esult -eld contains the numeric value o" the le"tmost position o" the compare string, i"
"ound string. ther,ise result -eld is set to Eero. I" the SCAN succeeds in -nding the
compare string ,ithin base string an indicator in DF position turns on.
Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXA1#
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE 0,U3ESAR0F2,1 B
0001.01 !2//3-.G F/R SR-.G 0,U3E0-. F2,1
000#.00 C 0,U3E0 SCA. F2,1 RES1 #0
000$.00 C RES1 ,SP2Y
000%.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000#.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
0,U3E0 SCA. F2,1 RES1
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
# 0

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s

' Du%eStar Technologies Pvt. (td.
7*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 3omparator String# (ength ?;andatory@ 3har#
Numeric
,act&r 2 !ase String# Start Position ?;andatory@ 3har#
Numeric
#e'ult ,ield <esult String ?ptional@ i" indicator in DF
HI
LO D< ?ptional@
E3 I" <esult is blan% & ?;andatory@
String Handling
Day 7
CHEC" -C.ec4 C.aracter'0
The "ormat o" 3HD3G is similar to S3=N. Ho,ever there are signi-cant diBerences
bet,een 3HD3G and S3=N. S3=N loo%s "or the presence o" the entire compare string and
notes do,n the location o" occurrence ,hereas 3HD3G detects the presence o" non.
speci-ed characters. 3HD3G is use"ul "or veri-cation o" characters ,ithin base string. =n
indicator is positioned in /6./7?DF@. This indicator turns on i" 3HD3G -nds one or more
unmatched characters in based string.
C
ol
um
ns
.
.
.
:
1 71 Edit PB01U01S/MYRPG
SEU==> EXA1$
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE 0,U3ESAR0F2,1 B
000#.00 C 0,U3E0 C@EC3F2,1:1 RES1 #0
000$.00 C RES1 ,SP2Y
000%.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000#.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
0,U3E0 C@EC3 F2,1:1 RES1
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
# 0

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s
' Du%eStar Technologies Pvt. (td.
6*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 3omparator String ?;andatory@ 3haracter
,act&r 2 !ase String# Start Position ?;andatory@ 3har#
Numeric
#e'ult ,ield <esult String ?ptional@ i" indicator in DF
HI
LO D< ?ptional@
E3 I" <esult is blan% & ?;andatory@
String Handling
Day 7
CHE"# -C.ec4 #ever'e0
3HDG< ,or%s eAactly li%e 3HD3G, eAcept that it chec%s the based string "rom right to le"t
rather than le"t to right. This opcode can be used to locate the rightmost invalid
character in a string or to determine the length o" string o" non.blan% character ,ithin a
-eld.

C
ol
um
ns
.
.
.
:
1
71 Edit PB01U01S/MYRPG
SEU==> EXA1%
FM C .....C20.01.0#.0$F+8to41"""/58d(F+8to4#"""R(sult2(n,@@i2oE7Comm(nts""""
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 C M/DE 0,U3ESAR0F2,1 B
000#.00 C 0,U3E0 C@E3RF2,1:B RES1 #0
000$.00 C RES1 ,SP2Y
000%.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000#.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
0,U3E0 C@E3R F2,1:B RES1
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
# 0

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s
' Du%eStar Technologies Pvt. (td.
7*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 3omparator String ?;andatory@ 3haracter
,act&r 2 !ase String# Start Position ?;andatory@ 3har#
Numeric
#e'ult ,ield <esult String ?ptional@ i" indicator in DF
HI
LO D< ?ptional@
E3 I" <esult is blan% & ?;andatory@
String Handling
Day 7
$LATE -Tran'late0
3haracters in the source string ?"actor1@ are translated according to the 9From: and 9ToH
strings ?both in "actor )@ and put into a receiver -eld ?result -eld@. I(=TD starts
translating the source "rom le"t to right.
Columns . . . : 1 71 Edit PB01U01S/MYRPG
SEU==> EXA1&
FM . .....-...............+m(d8onst+nt"""""""""C.........Fldnm(.............
!!!!!!!!!!!!!!! B()innin) o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0001.00 - 0ABC,EFG@-H32M./PGRSFC @-
000#.00 - 0UD1XYE0
000$.00 - 0+98d(*);iI=lmno574stFC 2/
000%.00 - 0u<J:6K0
000&.00 C M/DE 0du=(st+40F2,1 B
000'.00 C 2/:@- X2AEF2,1 F2,# B
0007.00 C F2,# ,SP2Y
000B.00 C SE/. 2R
!!!!!!!!!!!!!!!!!! End o* d+t+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
P4om5t t65( . . . C S(7u(n8( num9(4 . . . 000'.00

2(<(l .01.0#.0$ F+8to4 1 /5(4+tion F+8to4 # R(sult
2/:@- X2AE F2,1 F2,#
,(8im+l
2(n)t; Positions @/./P @- 2/ EG Comm(nt
B

F$=E:it F%=P4om5t F&=R(*4(s; F11=P4(<ious 4(8o4d
F1#=C+n8(l F#$=S(l(8t 54om5t F#%=Mo4( =(6s

' Du%eStar Technologies Pvt. (td.
)+*)+
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies
Pvt. Ltd.
,act&r 1 From String# To ?;andatory@ 3har#3har
,act&r 2 String# Start Position ?;andatory@ 3har#
Numeric
#e'ult ,ield <esult String 3haracter
HI
LO D< ?ptional@
E3

Você também pode gostar