Who can help me to pick up the last record ...

croby

Registered User.
Local time
Today, 19:50
Joined
Feb 27, 2003
Messages
29
Who can help me to pick up the last record in each partially duplicated group?

I have an sample input file with two fields, like this:

"PRCP","*ALIAS"
"PRCP.ACCT.BILLING.SUMMARY.DOWNLOAD","MIGRAT2"
"PRCP.ACCT.MUNCIPAL.BILL.DOWNLOAD","MIGRAT2"
"PRCP.ACCT.SUMMARY.DOWNLOAD","MIGRAT2"
"PRCP.ACCT.SUMMARY.DOWNLOAD.D100202","MIGRAT2"
"PRCP.ADDRESS.UPDATE.TRAN","??????"
"PRCP.ADDRESS.UPDATE.TRAN.G0086V00","MIGRAT2"
"PRCP.ADDRESS.UPDATE.TRAN.G0087V00","MIGRAT2"
"PRCP.ADDRESS.UPDATE.TRAN.G0088V00","MIGRAT2"
"PRCP.ADDRESS.UPDATE.TRAN.G0089V00","MIGRAT2"
"PRCP.ADDRESS.UPDATE.TRAN.G0090V00","MIGRAT2"
"PRCP.ENRCNT.EXPN405S.T3407903","??????"
"PRCP.ENRCNT.EXPN405S.T3407903.G0001V00","MIGRAT2"
"PRCP.ENRCNT.EXTRCTRN.T3461240.TRN2701","MIGRAT2"
"PRCP.ENRCNT.KEYDATA.LENGTH80","?????"
"PRCP.ENRCNT.KEYDATA.LENGTH80.G1158V00","MIGRAT2"
"PRCP.ENRCNT.KEYDATA.LENGTH80.G1159V00","MIGRAT2"
"PRCP.ENRCNT.KEYDATA.LENGTH80.G1160V00","MIGRAT2"
"PRCP.ENRCNT.KEYDATA.LENGTH80.G1161V00","MIGRAT2"

My program is like this:

Option Explicit
Private Sub Main()
Dim strName As String
Dim strRemark As String
Dim YGDG As String, YData As String, YVSAM As String
Static TotGDG As Integer, TotData As Integer
'
TotGDG = 0
TotData = 0
YVSAM = " "
YGDG = " "
YData = " "
Open App.Path & "\PRCP_IN3.txt" For Input As #5
Open App.Path & "\PRCP_OUT5.txt" For Output As #6
Do While Not EOF(5)
Input #5, strName, strRemark
If Right(strName, 3) <> "V00" Then
If strRemark = "??????" Then (or “?????”)
YGDG = "Y"
YData = " "
TotGDG = TotGDG + 1
Write #6, strName, strRemark, YGDG, YVSAM, YData
Else
YGDG = " "
YData = "Y"
TotData = TotData + 1
Write #6, strName, strRemark, YGDG, YVSAM, YData
End If
End If
Loop
Write #6, "PRCP Total GDG IS:", TotGDG
Write #6, "PRCP Total Data sets IS:", TotData
Close #5
Close #6
End Sub

This program works. It generated the output file:

"PRCP","*ALIAS"
"PRCP.ACCT.BILLING.SUMMARY.DOWNLOAD","MIGRAT2"," "," ","Y"
"PRCP.ACCT.MUNCIPAL.BILL.DOWNLOAD","MIGRAT2"," "," ","Y"
"PRCP.ACCT.SUMMARY.DOWNLOAD","MIGRAT2"," "," ","Y"
"PRCP.ACCT.SUMMARY.DOWNLOAD.D100202","MIGRAT2"," "," ","Y"
"PRCP.ADDRESS.UPDATE.TRAN","??????","Y"," "," "
"PRCP.ADDRESS.UPDATE.TRAN"," "," "," "," "
"PRCP.ENRCNT.EXPN405S.T3407903","??????","Y"," "," "
"PRCP.ENRCNT.EXPN405S.T3407903"," "," "," "," "
"PRCP.ENRCNT.EXTRCTRN.T3461240.TRN2701","MIGRAT2"," "," ","Y"
"PRCP.ENRCNT.KEYDATA.LENGTH80","?????","Y"," "," "
"PRCP.ENRCNT.KEYDATA.LENGTH80"," "," "," "," "
"prcp Total GDG IS:",3
"prcp Total Data sets IS:",5

Actually, I really want to include the following 3 records, which my program did not pick up.
Who can add some coding to my program to let the following records be included in the output file?

"PRCP.ADDRESS.UPDATE.TRAN.G0090V00","MIGRAT2"
"PRCP.ENRCNT.EXPN405S.T3407903.G0001V00","MIGRAT2"
"PRCP.ENRCNT.KEYDATA.LENGTH80.G1161V00","MIGRAT2"

Any Help, Tip, Hint to solve this problem will be greatly appreciated. Chris
 
Croby,

The lines where the names end in "V00" are not being
written anywhere. See the comments in the code.

Code:
Dim strName As String
Dim strRemark As String
Dim YGDG As String, YData As String, YVSAM As String
Static TotGDG As Integer, TotData As Integer
'
TotGDG = 0
TotData = 0
YVSAM = " "
YGDG = " "
YData = " "
Open "C:\test.dat" For Input As #5
Open "C:\output.dat" For Output As #6
While Not EOF(5)
Input #5, strName, strRemark
If Right(strName, 3) <> "V00" Then
   If strRemark = "??????" Then
      YGDG = "Y"
      YData = " "
      TotGDG = TotGDG + 1
      Write #6, strName, strRemark, YGDG, YVSAM, YData
   Else
      YGDG = " "
      YData = "Y"
      TotData = TotData + 1
      Write #6, strName, strRemark, YGDG, YVSAM, YData
   End If
   '
   ' This is the code where Rightr(strName, 3) = "V00"
   ' It does nothing
   ' Insert code to process these lines ...
   '
End If
Wend
Write #6, "PRCP Total GDG IS:", TotGDG
Write #6, "PRCP Total Data sets IS:", TotData
Close #5
Close #6

Wayne
 
croby,

oops, forget the ELSE ...

Code:
If Right(strName, 3) <> "V00" Then
   If strRemark = "??????" Then
      YGDG = "Y"
      YData = " "
      TotGDG = TotGDG + 1
      Write #6, strName, strRemark, YGDG, YVSAM, YData
   Else
      YGDG = " "
      YData = "Y"
      TotData = TotData + 1
      Write #6, strName, strRemark, YGDG, YVSAM, YData
   End If
Else  ' You need to add this line
   '
   ' This is the code where Rightr(strName, 3) = "V00"
   ' It does nothing
   ' Insert code to process these lines ...
   '
End If

Wayne
 
Hi. Thanks for the replies. Now I changed some codes. It's better.The data file has 3 "V00" groups. I want to pick up the name of the group and the last member of the group. My modified codes only pick up one of them:

Option Explicit
Private Sub Main()

Dim strName As String
Dim strRemark As String
Dim YGDG As String, YData As String, YVSAM As String
Dim bHaveGDG As Boolean, sHoldGDG As String, sHoldRemark As String
Dim MyCheck As Boolean
Static TotGDG As Integer, TotData As Integer
'
TotGDG = 0
TotData = 0
YVSAM = " "
YGDG = " "
YData = " "
bHaveGDG = False


Open App.Path & "\PRCP_SEQ_TEST.txt" For Input As #5
Open App.Path & "\PRCP_TEST_OUT1.txt" For Output As #6

Do While Not EOF(5)
Input #5, strName, strRemark
MyCheck = strName Like "*V00*"

If MyCheck = False And strRemark = "??????" Then
YGDG = "Y"
YData = " "
TotGDG = TotGDG + 1
Write #6, strName, strRemark, YGDG, YVSAM, YData
bHaveGDG = True
End If

If MyCheck = True Then
sHoldGDG = strName
sHoldRemark = strRemark

End If

If Not MyCheck And bHaveGDG And strRemark <> "??????" Then
YGDG = " "
YData = " "
Write #6, sHoldGDG, sHoldRemark, YGDG, YVSAM, YData
YData = "Y"
' Write #6, strName, strRemark, YGDG, YVSAM, YData
' TotData = TotData + 1
bHaveGDG = False
sHoldGDG = " "
sHoldRemark = " "
End If

If Not MyCheck And strRemark <> "??????" And Not bHaveGDG Then
YGDG = " "
YData = " Y"
TotData = TotData + 1
Write #6, strName, strRemark, YGDG, YVSAM, YData
End If

Loop
Write #6, "PRCP Total GDG IS:", TotGDG
Write #6, "PRCP Total Data sets IS:", TotData

Close #5
Close #6
End Sub

The output is like:

"PRCP.ACCT.BILLING.SUMMARY.DOWNLOAD","MIGRAT2"," "," "," Y"
"PRCP.ACCT.MUNCIPAL.BILL.DOWNLOAD","MIGRAT2"," "," "," Y"
"PRCP.ACCT.SUMMARY.DOWNLOAD","MIGRAT2"," "," "," Y"
"PRCP.ACCT.SUMMARY.DOWNLOAD.D100202","MIGRAT2"," "," "," Y"
"PRCP.ADDRESS.UPDATE.TRAN","??????","Y"," "," "
"PRCP.ENRCNT.EXPN405S.T3407903","??????","Y"," "," "
"PRCP.ENRCNT.EXPN405S.T3407903.G0001V00","MIGRAT2"," "," "," "
"PRCP.ENRCNT.EXTRCTRN.T3461240.TRN2701","MIGRAT2"," "," "," Y"
"PRCP.ENRCNT.KEYDATA.LENGTH80","??????","Y"," "," "
"PRCP Total GDG IS:",3
"PRCP Total Data sets IS:",5

I still miss the member under PRCP.ADDRESS.UPDATE.TRAN
and PRCP.ENRCNT.KEYDATA.LENGTH80

Any idea where I coded wrong? I know you can figure out. Please help. Thanks a lot! Chris
 

Users who are viewing this thread

Back
Top Bottom