I have input file which transferred to Mainframe using FTP from Windows. this is comma separated text file. while transferring, i have used FTP commands as (QUOTE SITE ENCODING=MBCS QUOTE SITE MBDATACONN=(UTF-8,UTF-8). in mainframe i have stored as variable block file
Input file from Windows
9992,王清, ID card,1123233
in mainframe, it showed input as below
Õ]×......Xþ»W½eVýþ.+/ÈÑ?>/%.ñà.Ä/ÊÀ...................
in hex format
FIN-OWNER-RECORD =Õ]×......Xþ»W½eVýþ.+/ÈÑ?>/%.ñà.Ä/ÊÀ...................
4CCD6DEDCD6DCCDDC47EBB333332E88EB8E88246766666244266762333333333333333333
069506655909536940EFBF80012C7EB6855DECE149FE1C09403124C220102196301073331
Could you please help me how to locate comma delimiter(,) in cobol, i was trying as below codes, none of them worked.
IF FIN-OWNER-RECORD(1:INDEX-VAL) = N","
IF FIN-OWNER-RECORD(3:INDEX-VAL) = X'2C'
To avoid a lot of headaches in the future, any (text) file transmitted from Windows environment to mainframe needs to be translated from ASCII to EBCDIC.
Otherwise endless series of tricks and gimmicks shall be required at each step while working with this dataset in mainframe environment. Your example is only the first problem in this way out of hundreds or thousands of further problems with this approach.
P.S.
First of all, learn how to use code tags when posting your code
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
Quote:
IF FIN-OWNER-RECORD(1:INDEX-VAL) = N","
IF FIN-OWNER-RECORD(3:INDEX-VAL) = X'2C'
You did not bother to tell us the value of INDEX-VAL so to some degree we can only guess what you're doing here. However, I don't think either of these statements is doing what you think it is. The first one looks at FIN-OWNER-RECORD starting at position 1 for a length of INDEX-VAL and attempts to match a single National comma to that string. If INDEX-VAL is not 1, then the comparison fails because you're comparing multiple bytes of FIN-OWNER-RECORD to a single byte. And if INDEX-VAL is one, the only time the comparison works is when there is a comma in the first position of FIN-OWNER-RECORD. The second statement does exactly the same thing, but looking at FIN-OWNER-RECORD starting in position 3 instead of 1, and using hex '2C' instead of a National comma. Since the record you posted doesn't have a comma (X'2C') until position 10, neither of your IF statements will be true for that record.
And I have to agree -- unless you have specific reasons (such as binary or packed decimal data), you should ALWAYS translate to EBCDIC on the mainframe. This makes everything much easier for you.
As suggested, i have moved file to mainframe as EBCDIC file
during FTP, i have used as below
QUOTE SITE MBDATACONN=(UTF-8,IBM-937)
now in mainframe, the file looks as below
80012,g..f8.e..,National ID card,220102196301073331
Actual file as below from windows
80012,王清华,National ID card,220102196301073331
In cobol program, i have used the below code to convert
MOVE FUNCTION NATIONAL-OF(WS-CONTACT-NM,937) TO
WS-CONTACT-NM-NA --> national type variable
MOVE FUNCTION DISPLAY-OF(WS-CONTACT-NM-NA,937) TO
WS-CONTACT-NM-UTF8
Still chinse characters are not inserted in table correctly, it is showing as below
gÚÚÚÚÚÚÚÚ
As suggested, i have moved file to mainframe as EBCDIC file
during FTP, i have used as below
QUOTE SITE MBDATACONN=(UTF-8,IBM-937)
now in mainframe, the file looks as below
80012,g..f8.e..,National ID card,220102196301073331
Actual file as below from windows
80012,王清华,National ID card,220102196301073331
In cobol program, i have used the below code to convert
MOVE FUNCTION NATIONAL-OF(WS-CONTACT-NM,937) TO
WS-CONTACT-NM-NA --> national type variable
MOVE FUNCTION DISPLAY-OF(WS-CONTACT-NM-NA,937) TO
WS-CONTACT-NM-UTF8
Still chinse characters are not inserted in table correctly, it is showing as below
gÚÚÚÚÚÚÚÚ
Please help on this
Your Windows file is a mixture of text, and binary data. It cannot be transmitted in a simple manner - neither as translated text file, nor as non-translated binary file.
Transmittal of binary fields from Windows file to mainframe dataset doesn’t make sense at all in 99.99% of cases, because binary data representation is completely different on different hardware platforms.
Typical method of data transfer in ETL tasks:
1) unpack all non-text fields of Windows file to their character presentation
2) transfer Windows full-text file to mainframe dataset, with conversion ASCII->EBCDIC
3) handle mainframe text-only dataset in normal manner...
These are the basics of any typical and standard IT job.
Unless you started to learn the major methods used in IT, it doesn’t make sense to start working on any real task, besides of some training, or playing computer games.
P.S.
It’s a pity you cannot learn even: how to use the code tags in your posts.
I wonder how the application design was done
requirements VS architecture VS implementation
with a bit of prototyping to confirm the approach for critical items
or not done as in this case
since we know nothing about the application requirements and architecture
the proper answer IMO should be ...
talk to the application analysts to find out