Cobol Picture Clause Binary Options


Klausa PENGGUNAAN Klausa PENGGUNA menentukan format item data dalam memori komputer atau dalam catatan file. Dalam beberapa situasi, format catatan-catatan item data mungkin berbeda dari format memori komputernya seperti yang ditentukan oleh klausa USAGE Hal ini dapat Terjadi ketika sistem file non-COBOL dengan format penyimpanan data yang berbeda diakses melalui antarmuka. Misalnya, Acu4GL menggunakan SQL untuk mengakses sistem file non-COBOL, dan dalam proses terjemahan terjadi pada data. Catatan Ada banyak opsi kompilator untuk Yang mempengaruhi perilaku penyimpanan data Lihat Data Storage Options di bagian Kompatibilitas ACUCOBOL-GT. Kolom di sebelah kiri menunjukkan singkatan yang diterima untuk persyaratan di sebelah kanan. Klausa PENGGUNA dapat digunakan dalam entri deskripsi data kecuali yang memiliki nomor urut 66 , 78, dan 88.A klausa PENGGUNA tidak boleh digunakan dengan item data floating-point eksternal. Jika klausa PENGGUNAAN ada di entri deskripsi data untuk item grup, maka setiap klausa PENGGUNAAN yang muncul untuk entrie bawahan S harus dari jenis yang sama. Klip PICTURE dari item COMP, COMP-1, COMP-2, COMP-3, COMP-4, COMP-5, COMP-6, BINARY, atau PACKED-DECIMAL hanya dapat berisi Simbol-simbol 9, S, V, dan P COMP-6 mungkin tidak menggunakan simbol S. String PICTURE dari item COMP-X atau COMP-N hanya boleh berisi 9 simbol atau semua simbol X. Entri deskripsi data untuk sebuah PENGGUNAAN INDEX item data tidak dapat berisi klausa berikut berikut BLANK WHEN ZERO, JUSTIFIED, PICTURE, dan VALUE IS. Level 88 item mungkin tidak dispesifikasikan untuk USAGE IS INDEX data item. Entri deskripsi data untuk item data PENGGUNAAN POINTER Tidak dapat berisi klausa berikut berikut BLANK WHEN ZERO, JUSTIFIED, atau PICTURE Item data POINTER mungkin memiliki klausa nilai yang ditentukan untuk itu, namun nilainya harus berupa kata NULL. Entri deskripsi data untuk PENGGUNAAN FLOAT ATAU PENGGUNAAN Item data DOUBLE tidak dapat berisi klausul berikut BLANK KETIKA item ZERO, JUSTIFIED, atau PICTURE FLOAT atau DOUBLE data mungkin memiliki nilai klausa Nilai ma Y menjadi floating point literal, numerik literal, atau kata ZERO Berikut adalah contoh dari item data Storage Work Storage. Berikut ini secara kolektif disebut tipe data tipe C SIGNED-INT, UNSIGNED-INT, SIGNED-SHORT , UNSIGNED-SHORT, SIGNED-LONG, UNSIGNED-PANJANG Tipe data ini serupa dengan tipe data yang terdapat dalam bahasa pemrograman C. Entri deskripsi data untuk tipe data bergaya C tidak dapat berisi klausa berikut berikut BLANK WHEN ZERO, JUSTIFIED, atau PICTURE. Control-type adalah salah satu tipe tipe kontrol grafis yang diketahui oleh compiler, seperti LABEL atau ENTRY-FIELD, atau nama ActiveX, COM, atau control. Entri deskripsi data untuk item data USAGE HANDLE Mungkin tidak mengandung klausa berikut berikut BLANK WHEN ZERO, JUSTIFIED, atau PICTURE Jika mengandung klausa VALUE, nilai yang ditentukan harus berupa kata NULL. Font-name adalah salah satu pengenal berikut DEFAULT-FONT, FIXED-FONT, TRADISIONAL - FONT, KECIL-FONT, MEDIUM-FONT, BESAR-FONT. Perlu dicatat juga Pilihan - Df atau opsi - Cv akan menyebabkan compiler memperlakukan COMP-1 dan COMP-2 sebagai FLOAT dan DOUBLE. Untuk informasi lebih lanjut, lihat bagian 5 4 di Transitioning to ACUCOBOL-GT. Layout-name adalah nama Dari salah satu pengelola tata letak standar sistem Saat ini, ini hanya bisa berupa LM-RESIZE. A klausa PENGGUNAAN yang ditulis pada tingkat kelompok berlaku untuk setiap item dasar yang berada di bawah item grup tersebut. Jika tidak ada klausa PENGGUNAAN ditentukan, maka PENGGUNAAN DISPLAY adalah Tersirat. Format internal dari item PENGGUNAAN DISPLAY adalah ASCII. Format dari item indeks adalah biner yang ditandatangani 32-bit Ukurannya selalu empat, dan ini memiliki rentang nilai dari -2147483647 sampai 2147483647 Bila menggunakan tombol kompilasi untuk Kompatibilitas dengan versi sebelum 6 0 0 - Z52 misalnya item indeks adalah biner unsigned 16-bit, ukuran selalu dua, dan menyimpan nilai dari 0 sampai 65535. Format item data COMP-1 adalah 16-bit signed Biner Nilai hukum berkisar antara -32767 sampai 32767 Ukuran item data selalu dua Byte, dan setengah orde tinggi data disimpan di byte paling kiri String PICTURE yang menjelaskan item tidak relevan Tidak seperti tipe data numerik lainnya, kesalahan ukuran akan terjadi pada COMP-1, COMP-X, atau COMP - N item data hanya jika nilainya melebihi penyimpanan fisik item dengan kata lain, jumlah 9 s pada item s PICTURE diabaikan saat kesalahan ukuran ditentukan. Untuk penyimpanan desimal COMP-2, masing-masing digit disimpan dalam satu byte. Dalam format desimal Jika nilai ditandatangani, maka tambahan trailing byte dialokasikan untuk tanda Penyimpanan COMP-2 identik dengan PENGGUNAAN DISPLAY dengan orde tinggi empat bit yang dilucuti dari setiap byte. Untuk penyimpanan KOMP-3 dikemas-desimal , Dua digit disimpan di setiap byte Satu byte tambahan dialokasikan untuk tanda itu, bahkan jika nilainya tidak bertanda Tanda itu ditempatkan di posisi paling kanan, dan nilainya 0x0D untuk nilai negatif semua lainnya diperlakukan sebagai aturan positif tapi lihat. 18 di bawah Ukuran item termasuk satu untuk impl Ied sign dibagi dua untuk sampai pada frase pembulatan aktualnya. Format dari item COMP-4 adalah dua s-complement biner nilainya tanpa nilai desimalnya Nilai COMP-4 disimpan dalam format independen mesin Format ini Tempatkan bagian pesanan tertinggi dari nilai di posisi paling kiri dan mengikuti ke bagian orde rendah di posisi paling kanan Jumlah byte yang dimiliki item data tergantung pada jumlah 9 s pada GAMBAR dan pada adanya berbagai Pilihan waktu kompilasi Misalnya, Anda mungkin menyertakan lebih dari delapan belas tahun 9 s jika program Anda telah disusun untuk dukungan 31 digit. Ini ditunjukkan pada tabel berikut. Catatan Di mana dua nilai diberikan, nilai yang lebih kecil berlaku untuk item data unsigned. , Dan nilai yang lebih besar berlaku untuk item data yang ditandatanganiP-5 terutama digunakan untuk berkomunikasi dengan program eksternal yang mengharapkan penyimpanan data asli. Format item data COMP-5 identik dengan item data COMP-4, kecuali data tersebut adalah Disimpan dalam mesin-d Ependent format Ini disimpan dalam urutan yang alami ke mesin host Misalnya, item data PIC S9 9 COMP-5 setara dengan kata biner 32 bit pada mesin host, dan item PIC S9 20 COMP-5 Adalah setara dengan kata 64-bit. Data yang tersimpan dalam bidang COMP-5 mungkin tidak dapat diangkut ke mesin lain karena mesin yang berbeda memiliki urutan byte alami yang berbeda. Pada banyak mesin 68000, kebanyakan RISC, COMP-5 identik dengan COMP - 4 Pada yang lain 80x86, VAX, sama dengan byte dalam urutan terbalik. NILAI VALUE untuk item data COMP-5 disimpan dalam format mesin-independen dan disesuaikan saat dimasukkan ke dalam item data. Hal ini memastikan Bahwa nilainya sama dari mesin ke mesin. Pada toko aritmatika dan non-aritmatika menjadi barang COMP-5, jika pemotongan diperlukan, secara default ACUCOBOL-GT dipotong dalam desimal dengan jumlah digit yang diberikan dalam klausa PICTURE Anda dapat menggunakan Opsi kompresor - TruncANSI untuk memaksa pemotongan dalam biner terhadap kapasitas pengalokasian Penyimpanan atur item COMP-5 Opsi - Dz dan --noTrunc juga mempengaruhi pemotongan Lihat Buku 1, bagian 2 1 9, Opsi Penyimpanan Data, untuk informasi lebih lanjut. Level 01 dan data 77 item yang COMP-5 disinkronkan secara otomatis. Ke batas mesin yang sesuai, terlepas dari pengaturan waktu kompilasi ini memungkinkan Anda untuk meneruskan barang-barang ini dengan aman ke subrutin C tanpa harus mempedulikan diri Anda dengan keselarasan. Jika COMP-5 digunakan dengan item data PIC X n dan diberi nilai alfanumerik , Hasilnya tidak terdefinisi Misalnya, fragmen kode berikut menyebabkan NUM memiliki nomor yang tidak terdefinisi dan nilai yang dihasilkan untuk baris terakhir adalah 100. Item data PIC X n yang digunakan dengan COMP-5 tidak dapat ditandatangani. Format a Item COMP-6 identik dengan item COMP-3 kecuali yang unsigned dan tidak ada ruang yang dialokasikan untuk tanda Jika jumlah digitnya ganjil, nol ditambahkan ke ujung kiri nomor sebelum dikemas. Jadi ada Adalah dua digit desimal per byte, dan ukuran sebenarnya dari Item ditentukan dengan membagi ukuran PICTURE menjadi dua dan pembulatannya. Item data COMP-X harus dijelaskan dengan string gambar yang terdiri dari hanya 9 atau hanya simbol X. Dalam kedua kasus tersebut, item data diperlakukan sebagai unsigned binary integer , Dengan penyimpanan internal yang serupa dengan item data COMP-4 Jika simbol X digunakan untuk menggambarkan item, jumlah byte yang dialokasikan ke item sama dengan jumlah simbol X pada string gambar Jika 9 simbol adalah Digunakan sebagai gantinya, maka jumlah byte yang dialokasikan adalah jumlah byte paling sedikit yang diperlukan untuk menampung sejumlah ukuran itu. Misalnya, data barang PIC 99 akan dialokasikan 1 byte item data PIC 9 9 akan dialokasikan 4 byte. Jumlah 9 simbol pada string gambar item, nilai maksimum yang dapat disimpan dalam item COMP-X ditentukan oleh jumlah byte yang dialokasikan untuk itu sampai maksimum 18 digit, atau maksimal 31 digit jika 31 - digit support berlaku Sebagai contoh, item COMP-X yang terdiri dari 1 b Anda dapat menyimpan sejumlah angka dari 0 sampai 255 Nomor 2-byte COMP-X dapat ditahan dari 0 sampai 65535 Kesalahan ukuran terjadi pada item COMP-X hanya jika nilainya lebih besar daripada item data yang dapat ditahan secara fisik. Saat COMP - X digunakan dengan item data PIC X, maksimumnya adalah PIC X 8 Maksimum ini dinaikkan ke PIC X 16 bila support 31 digit berlaku. Item data COMP-N identik dengan item data COMP-X, Kecuali bahwa data disimpan dalam format asli mesin host, bukan format mesin-independen. Butir data yang digambarkan sebagai PACKED-DECIMAL identik dengan COMP-3 Anda dapat menyebabkan unsigned PACKED-DECIMAL diperlakukan sebagai COMP-6 dengan menggunakan Pilihan waktu kompilasi. Secara default, item data BINARY identik dengan item data COMP-4. Pilihan waktu kompilasi - D5 memperlakukan item data BINARY sebagai item COMP-5. Dalam mode kompatibilitas VAX COBOL, item data COMP Sama seperti COMP-4 dan diperlakukan sebagai data biner Dalam mode kompatibilitas RM COBOL, COMP sama dengan COMP-2 Anda dapat menggunakan opsi waktu kompilasi untuk cha Nge perilaku default. Item data pointer diperlakukan sebagai item data numerik unsigned Format internal berbeda untuk setiap item item item Pointer yang dimaksudkan untuk menyimpan alamat dari item data lainnya lihat Pernyataan SET Item data pointer mungkin memiliki klausa VALUE yang ditentukan Untuk itu, tapi nilai yang ditentukan harus berupa kata NULL Ini menunjukkan bahwa pointer saat ini tidak menunjuk ke item manapun Jika sebuah pointer tidak secara eksplisit diberi nilai awal, maka nilai awalnya adalah sewenang-wenang. Item data utama menempati 8 byte. Ini menyediakan Cukup ruang untuk menampung alamat pada mesin 64-bit Jika Anda menggunakan mesin yang lebih kecil, runtime hanya menggunakan 4 byte data item pointer pertama yang tertinggal 4 byte tetap ada di memori, mereka hanya dibiarkan tidak terpakai Anda dapat menggunakan - Opsi kompilasi-waktu Dw untuk menyesuaikan ruang yang dialokasikan ke item data pointer Anda dapat melakukan ini untuk menghemat penyimpanan jika Anda tahu Anda tidak akan berjalan pada mesin 64-bit. Pointer dapat digunakan dalam ekspresi kondisional, di mana mereka berada N dibandingkan satu sama lain atau dengan nilai NULL Perbandingan antara pointer harus sama atau tidak sama dengan yang lebih besar dan kurang dari perbandingan tidak diperbolehkan. evelevel 01 dan level 77 item data yang item POINTER disinkronkan secara otomatis ke mesin yang sesuai Batas, terlepas dari pengaturan waktu kompilasi ini memungkinkan Anda untuk meneruskan barang-barang ini dengan aman ke subrutin C tanpa harus mempedulikan keselarasan diri Anda sendiri. Kecuali untuk sinkronisasi otomatis, item data PENGGUNAAN POINTER diperlakukan dalam semua hal seperti item data USAGE UNSIGNED-LONG Ini menangani semua mesin saat ini dengan benar Perilaku ini dapat berubah untuk memenuhi persyaratan beberapa mesin masa depan. Item data titik-pemanasan disimpan dalam format yang bergantung pada mesin. Item PENGGUNAAN FLOAT memiliki 4 byte yang dialokasikan untuknya. PEMESANAN Item DOUBLE menempati 8 byte. Level 01 Dan 77 data item yang menggunakan PENGGUNAAN FLOAT atau DOUBLE disinkronisasi secara otomatis ke batas mesin yang sesuai, berapa pun waktu kompilasinya. Pengaturan Hal ini memungkinkan Anda untuk melewatkan barang-barang ini dengan aman ke subrutin C tanpa harus mempedulikan diri Anda dengan kesejajaran. Definisi ANSI COBOL tidak menyebutkan bagaimana tanda-tanda harus disimpan di bidang numerik kecuali untuk kasus SIGN IS SEPARATE ACUCOBOL-GT memungkinkan Anda memilih Konvensi penyimpanan tanda alternatif dengan menggunakan pilihan waktu kompilasi - Dca, - Dcb, - Dci, - Dcm, - Dcn, - Dcr, dan - Dcv Menentukan konvensi penyimpanan tanda terkadang berguna saat Anda mengekspor dan mengimpor data. Informasi tambahan, lihat Panduan Pengguna, bagian 2 2 10, Pilihan Penyimpanan Data. Lokakarya penyimpanan mempengaruhi bagaimana data muncul di jenis data USGS DISPLAY, COMP-2, dan COMP-3. Dalam USAGE DISPLAY, penyimpanan standar ASCII, jika tanda Dimasukkan ke dalam posisi digit, digit dikodekan sesuai dengan tabel berikut. Catatan yang ditandai dengan tanda bintang menunjukkan item ukuran tetap Item ukuran tetap berukuran sama tanpa memperhatikan mesin target Entri tanpa tanda bintang bervariasi dalam Ukuran Item ini akan menempati ruang sampai jumlah byte yang tercantum dalam tabel. Catatan Ukuran yang tercantum dalam tabel di atas mencakup semua mesin yang sekarang dan yang diantisipasi yang menjalankan ACUCOBOL-GT Arsitektur masa depan mungkin memerlukan perubahan pada ukuran maksimum yang ditetapkan pada item ini. Di lingkungan eksekusi, barang-barang ini bertindak dengan segala cara seolah-olah item itu berukuran tetap dengan ukuran yang sesuai. Misalnya, fragmen kode berikut. Akan mencetak 4 saat dijalankan pada mesin 32-bit, namun akan mencetak 8 Ketika dijalankan pada mesin 64-bit. Dalam contoh berikut, setiap byte diwakili oleh dua digit heksadesimal atau dengan karakter yang dikutip tunggal. Setiap nilai ditampilkan dalam berbagai format. Juga ditunjukkan adalah PENGGUNAAN DISPLAY menggunakan berbagai opsi SIGN Contoh berikut menggunakan Konvensi penyimpanan tanda ACUCOBOL-GT default. HANDLE item data membuat kelas data dan kategori mereka sendiri di COBOL Secara internal mereka disimpan sebagai nilai integer, dan berperilaku seperti angka saat digunakan Item data HANDLE biasanya digunakan untuk Simpan pegangan dari objek yang dibuat secara dinamis seperti jendela mengambang atau kontrol grafis. HANDLE item data masuk dalam dua bentuk yang diketik dan generik Anda membuat pegangan generik saat Anda menghilangkan frasa OF Anda membuat pegangan yang diketik saat Anda memasukkan frasa OF. Anda dapat menggunakan item data HANDLE hanya jika diizinkan secara eksplisit, atau sebagai bagian dari pernyataan MOVE, sebuah pernyataan CALL sebagai parameter, atau dalam ekspresi Boolean. Pegangan umum dapat digunakan dalam situasi dimana pegangan diizinkan Bila Anda menggunakan generik Atur sebagai sumber pernyataan MODIFY, Anda tidak akan dapat menggunakan properti khusus atau nama gaya kontrol apa pun dalam pernyataan ini. Hal ini karena pegangan generik dapat dikaitkan dengan jenis kontrol apa pun. Dalam kasus ini, kompilator tidak dapat menentukan mana Kumpulan nama gaya dan nama properti valid. Penanganan tipikal dapat digunakan dalam pernyataan di mana pegangan apapun diizinkan, atau bila Anda mengacu pada objek dari jenis pencocokan Misalnya, HANDLE OF WINDOW tidak dapat digunakan sebagai Tangani dalam pernyataan DISPLAY LABEL Sebagai gantinya, Anda harus menggunakan pegangan generik atau HANDLE OF LABEL Typed handle memungkinkan kompilator mengenali gaya dan nama properti yang terkait bila sesuai Typed handle juga memperbaiki keterbacaan program Anda dengan memberikan informasi tambahan tentang yang dimaksud. Penggunaan pegangan, selain memberikan pengecekan waktu kompilasi untuk memastikan bahwa Anda menggunakan pegangan dalam situasi yang sesuai. Handel dapat digunakan dalam perbandingan Hanya ada dua perbandingan yang berarti untuk memeriksa persamaan atau ketidaksetaraan dengan NULL, dan perbandingan dengan pegangan lain Item data Nilai pegangan NULL selalu menunjukkan pegangan yang tidak benar. Handel disimpan secara internal sebagai bilangan bulat biner 4 byte Informasi ini dapat berguna saat Anda melakukan debug pada program Anda dapat memeriksa nilai pegangan pada debugger Anda seharusnya tidak bergantung pada hal ini. Definisi dalam program Anda, bagaimanapun, karena dapat berubah sewaktu-waktu. Barang data data secara otomatis SYNCHRO NIZED pada batas 4 byte Perhatikan bahwa ini terjadi terlepas dari pengaturan opsi kompilasi waktu-Dl yang membatasi jumlah sinkronisasi Sistem runtime memerlukan tingkat keselarasan ini untuk menghindari kesalahan bus pada beberapa mesin. Jika font-name Ditentukan, maka item data yang dijelaskan oleh klausa PENGGUNA diinisialisasi pada startup program dengan penanganan huruf yang sesuai Tindakan ini identik dengan menempatkan pernyataan tersebut. Pada awal program Anda, di mana item data adalah item data yang dijelaskan oleh klausa PENGGUNAAN Dan nama font sama dengan nama font di klausa PENGGUNAAN. Baca Tata Letak COBOL. Tutorial tentang cara membaca tata letak COBOL ditulis khusus untuk pelanggan kami yang telah melakukan konversi yang dilakukan di Disc Interchange dan telah menerima tata letak COBOL Dengan data Ini dimaksudkan untuk memberi Anda cukup informasi untuk membaca tata letak yang paling sederhana. Ini tidak mencakup semua topik atau semua hal yang Anda temukan dalam tata letak yang rumit, dan ini dimaksudkan untuk menjelaskan COBOL la Youts hanya sehingga Anda dapat menggunakan data yang dikonversi Anda, tidak sehingga Anda dapat menulis program COBOL. Artikel ini dimulai di sini Membaca COBOL Layouts di mana Anda juga akan menemukan indeks topik. Bagian 4 Bidang Numerik. Bagian ini menjelaskan beberapa jenis data numerik dan penanganan Tanda dan titik desimal. Konten dari bagian ini. Perlu untuk mengubah bidang Numerik Itu bisnis kami. COBOL memiliki beberapa jenis bidang numerik Tipe data ini mencakup bidang DISPLAY, yang terdiri dari karakter karakter EBCDIC atau ASCII untuk 0-9, Bidang biner, bidang yang dikemas, dan bidang floating-point Ada juga pilihan untuk tanda tangan atau tanda yang terpisah atau tanda tumpang tindih, dan untuk desimal nyata atau tersirat Tipe data ditentukan oleh klausa USAGE IS. PENGGUNAAN ADALAH Klausul. Ada Sebenarnya lebih pada pernyataan gambar daripada yang telah kami jelaskan sebelumnya Ada klausa PENGGUNAAN yang menentukan jenis penyimpanan bidang numerik - tampilan, biner, atau komputasi Sintaks penuh, melalui sebuah contoh, adalah ini mengatakan kepada stor E bidang dalam format komputasi-3 Penggunaan adalah bagian yang opsional dan umumnya tidak aktif, dan komputasi dapat disingkat COMP, sehingga Anda akan lebih sering melihat tulisan ini Jenis bidang numerik yang biasanya Anda lihat di layout COBOL. Termasuk bidang Signed fieldsputational, atau comp. Display, termasuk bidang Signed atau Zoned, adalah yang paling umum, dan comp-3 adalah jenis bidang numerik kedua yang paling umum Beberapa kompiler juga memiliki tipe data comp-4 dan comp-5, biasanya untuk Meniru comp pada compiler lain. Usage adalah Display. Display format adalah default untuk angka di COBOL Jika tidak ada penggunaan klausa yang ditentukan, defaultnya adalah penggunaan display, yang berarti nilainya disimpan sebagai digit karakter EBCDIC, sebagai lawan biner. Nilai mungkin atau mungkin tidak memiliki desimal - tersirat atau nyata - dan mungkin tidak ditandatangani atau dilengkapi tanda tersemat atau terpisah - yang dapat berupa leading atau trailing Field format tampilan default signed berisi tanda trailing tertanam, dan bersama Mmonly disebut bidang Signed, atau IBM Signed, atau Zoned Tipe data ini dijelaskan di bawah. Field yang Disimpan. Ada tipe data numerik umum yang digunakan di COBOL pada mainframe IBM yang disebut Signed yang disebut IBM Signed, atau Zoned COBOL mewakili jenis bidang ini. Oleh S pada klausa gambar dari bidang format tampilan, misalnya PIC S9 6 A Field yang dituju terdiri dari karakter numerik EBCDIC biasa, satu karakter per byte, untuk semua digit kecuali yang memegang tanda, tanda yang paling signifikan Digit belakang yang paling penting atau paling tidak signifikan - biasanya digit paling tidak penting Angka yang memegang tanda itu digabungkan, atau di atas meninju tanda nomor ke angka itu Ini menghemat satu byte yang seharusnya ditempati oleh tanda Nilai dari itu Digit disimpan sebagai nilai biner, dan adalah OR d dengan kode tanda, yaitu D0 hex untuk bilangan negatif, hex C0 untuk nilai positif, dan nilai F0 hex untuk nilai unsigned. Karena overpunch, digit yang memegang tanda akan Tidak muncul sebagai Nomor bila field dilihat dalam mode karakter EBCDIC Jika Anda memiliki field dan melihat nilai 1 23 dengan editor EBCDIC, maka kompiler COBOL 0000012C. ASCII juga akan menggunakan tipe data Signed dengan overpunch, namun tanda bitnya Berbeda dan tidak standar antara kompiler Lihat Field Tandatangan singkat Tech-Talk kami untuk rincian lebih lanjut tentang bidang Signifikan EBCDIC dan ASCII. Diatur adalah bidang terpisah. KARTU COBOL menanamkan tanda pada nilai secara default lihat bidang yang ditandatangani di atas Tapi ada ketentuan Di COBOL untuk tanda yang terpisah, dan dapat mengarah atau membuntuti Pernyataan untuk ini adalah Ini dapat digabungkan dengan klausa utama atau trailing Pernyataan ini dapat diterapkan ke field item dasar atau ke seluruh field recordback dan Binary. Karena Komputer melakukan perhitungan dengan bilangan biner, lebih efisien untuk menyimpan nilai-nilai tersebut dalam file dalam bentuk biner asli daripada menyimpannya dalam basis dasar yang dapat dibaca manusia Jika nomor tersebut tersimpan dalam nat Format biner ive dapat di masukan dari file dan digunakan secara langsung Jika disimpan dalam format sepuluh dasar maka perlu dikonversi menjadi biner sebelum melakukan perhitungan di atasnya, kemudian dikonversi kembali menjadi basis sepuluh untuk penyimpanan. COBOL mendefinisikan beberapa jenis data biner. Kami akan mencantumkan ringkasan singkat di sini, dan Anda dapat menemukan lebih banyak detail di Computational Fields COBOL dan di COBOL Comp-3 Packed Fields Sebelum memulai, ada satu hal penting untuk memahami standar COBOL yang meninggalkan penerapan sebagian besar tipe data sampai dengan Vendor yang menulis kompiler COBOL Alasan untuk ini adalah karena komputer yang berbeda - CPU - menggunakan representasi biner yang berbeda secara internal, dan berfungsi paling baik dengan jenis bilangan biner mereka sendiri Pendekatan ini menghasilkan kompiler yang lebih baik dan lebih cepat, namun juga menyebabkan kebingungan, Karena tipe data comp pada satu mesin tidak harus sama dengan comp pada mesin lain. Tabel di bawah ini mencantumkan penggunaan umum tidak semua kompiler akan mengikuti jenis ini. Untuk deta lebih lanjut Il pada susunan kata dan tanda lihat tautan di atas. Jenis data yang digunakan lapangan untuk penyimpanan ditentukan oleh penggunaannya adalah klausa dalam definisi lapangan, dan dalam kebanyakan kasus, jumlah byte penyimpanan ditentukan oleh jumlah digit di PIC Floating point numbers mengikuti format biner standar dan karena ukurannya tidak ditentukan oleh PIC, dan tidak ada PIC yang digunakan dalam definisi lapangan. Deskripsi tentang bagaimana tipe data ini disimpan. Basis desimal biasanya diimplementasikan sebagai comp-3 Lihat comp -3.Ketika membaca spesifikasi bidang biner atau comp, ukuran yang tercantum di PIC adalah jumlah digit desimal setelah nomor tersebut dikonversi dari biner menjadi basis sepuluh. Dalam kasus bidang yang dikemas, ukurannya setelah membongkar. Desimal. Sebagian besar pemrogram PC cenderung berpikir dalam hal desimal nyata dalam nilai numerik Pada PC, jika Anda memiliki kolom dolar dan sen untuk, katakanlah, jumlah faktur, dalam jumlah 123 45, file akan berisi enam byte 123 45 dan mungkin sebuah tanda Dengan kata lain, ada Titik desimal nyata dalam file COBOL dapat melakukan ini juga, melalui OR berikut Kehadiran di PIC menyebabkan desimal nyata dalam file desimal tersirat, bagaimanapun, jauh lebih umum di COBOL. Implied Desimal. Implied decimal simply Berarti ada titik desimal yang tersirat pada lokasi tertentu di lapangan, namun tidak benar-benar tersimpan dalam file Lokasi desimal tersirat ditunjukkan oleh huruf V di PIC Menggunakan desimal tersirat akan menghemat ruang dalam file desimal tersirat dapat diterapkan pada Jenis bidang numerik, termasuk bidang yang dikemas, atau comp-3. Misalnya, adalah bidang desimal tersirat Ada 6 digit, maka desimal tersirat - angka V - dan 2 lagi, dengan total 8 digit Field is 8 byte dalam ukuran tidak ada dalam file - lokasi titik desimal tersirat berada di antara 9 6 dan 99 Jika bidang berisi 00000123 maka saldo akunnya adalah 1 23, karena ada desimal yang tersirat antara Dolar dan sen. Sinkronisasi dan Alignment. Topiknya adalah Sedikit yang terlibat untuk tutorial ini, tapi Anda harus menyadarinya Bila menggunakan binary storage biner dan comp, beberapa kompiler pada beberapa mesin mungkin meminta agar bidang numerik dimulai pada beberapa batas Misalnya, pada mesin 32 bit, mungkin memerlukannya. Medan comp dimulai pada batas 32 bit. Jika Anda menentukan bidang comp di tengah sebuah record, dan tidak terjadi untuk memulai pada batas 4 bit 32 bit, kompilator akan menyelaraskannya dengan batas 32 bit untuk melakukan sinkronisasi. Apa sebenarnya yang tersimpan dalam file mungkin tidak sama dengan PICs pada tata letak menunjukkan Ini bukan masalah yang sangat umum, sebagian karena bidang biner dan comp tidak begitu umum dalam file, namun Anda harus menyadarinya. Informasi. Untuk artikel lebih lanjut tentang konversi data, lihat Indeks Konversi TechTalk kami. Layanan Konversi COBOL kami. Perusahaan Layanan Interchange Interchange dapat mengubah sebagian besar jenis data numerik, termasuk semua tipe data mainframe IBM EBCDIC, dan kebanyakan tipe data ASCII dari sistem PC dan UNIX. Perpustakaan Rsion rutinitas memungkinkan kita untuk menangani pekerjaan yang sulit yang kompiler COBOL standar tidak bisa diubah. Suatu kondisi adalah potongan kode khusus yang memungkinkan Anda menginstruksikan komputer untuk membandingkan dua lembar data. Kondisi digunakan dalam laporan IF dan dalam klausa While Until clauses. Dari pernyataan PERFORM. Kondisi memiliki sintaks. Dimana data-1 dan data-2 bisa menjadi data literal atau field-2 juga bisa berupa COBOL literal seperti SPACES atau ZEROS. Operator dapat menjadi simbol perbandingan tradisional Untuk memeriksa Ketidaksetaraan digunakan TIDAK karena tidak semua kompiler menerima simbol Jarang, kompilator tidak akan menerima Anda dapat menggunakan TIDAK dan TIDAK Kembali ke Daftar Isi. Statements dapat dilanjutkan melalui beberapa baris tanpa melakukan sesuatu selain menempatkan kode pada baris yang terpisah Kompilator akan Cari tahu. Huruf alfanumerik yang sangat panjang dapat dilanjutkan pada banyak baris dengan menempatkan tanda hubung di kolom 7 dari garis kelanjutan dan menempatkan sisa literal di sana Kelanjutan dari lite ini. Ral membutuhkan sebuah kutipan tunggal awal Literal pada baris sebelumnya tidak memiliki kutipan tunggal yang berakhir tetapi dianggap meluas ke kolom 72. Tanda hubung pada baris kedua ada di kolom 7 Kutipan tunggal pada baris itu ada di kolom 12 dan Literal terus dari sana Kutipan tunggal yang berakhir pada baris itu diperlukan Perhatikan bahwa bagian literal yang ada pada baris pertama tidak memiliki kutipan akhir Jika E terakhir tidak ada dalam kolom 72 maka akan diasumsikan bahwa semua karakter antara Bahwa E dan kolom 72 adalah spasi dan akan muncul dalam literal. Juga berlaku dengan klausa nilai. Control Breaks. Control breaks adalah fitur laporan yang memungkinkan pengelompokan dan akumulasi subtotal untuk data yang dimiliki bersama berdasarkan nilai sebuah Lapangan bidang kontrol Bila nilai untuk bidang ini berubah dari satu rekaman ke rekaman lainnya, istirahat program untuk melakukan pemrosesan khusus seperti subtotal cetak sebelum berlanjut dengan rekaman berikutnya File masukan harus diurutkan pada c Bidang ontrol s. Contoh laporan dengan kontrol tingkat satu kontrol. Penghentian kontrol ada di departemen Setiap departemen kelompok kontrol memilikinya sendiri judulnya dan pijakan total Meskipun tidak ditunjukkan di sini dalam contoh ini, ini umum untuk judul kolom Untuk diulang setelah setiap pos kontrol. Lihat halaman algoritma untuk kode sampel. Pada dasarnya ada tiga jenis data yang dikenali oleh COBOL Data numerik baik dengan atau tanpa desimal hanya 0-9, titik desimal dan tanda yang diperbolehkan, hanya abjad Karakter AZ dan alfanumerik setiap karakter Abjad jarang digunakan. Math hanya dapat dilakukan pada bidang numerik. Data umum untuk program COBOL dan harus dimanipulasi sering Tanggal biasanya disimpan dalam format Gregorian, yang terdiri dari bulan, hari dan tahun yang akrab. Ini umumnya disebut format mmddyy, meskipun format mmddyyyy menjadi standar baru, lihat halaman diskusi Y2K. Meskipun format yang familiar bagi coders dan user dates adalah mor. E sering disimpan dalam format yymmdd atau yyyymmdd sehingga mudah dipilah dengan mudah. ​​Jadi disebut matematika kalender, di mana tanggal digunakan dalam perhitungan, bisa menjadi proses yang membosankan, kecuali kompilator Anda mendukung fungsi tanggal intrinsik. Jika tidak, ingat hal berikut tentang Kalender Gregorian. April, Juni, September dan November hanya memiliki waktu 30 hari. Februari hanya memiliki 28 hari, 29 jika tahun kabisat. Semua bulan lainnya memiliki 31 hari. Metode resmi untuk menentukan apakah setahun adalah tahun kabisat yang membutuhkan pembagian 4 digit tahun dengan 4, 100 dan 400 dan melihat sisa dari ketiga perhitungan tersebut. Jika remiander pertama adalah 0 maka tahun itu adalah tahun kabisat, tapi jika yang kedua juga 0 maka tahun bukanlah tahun kabisat, Tetapi jika sisanya yang ketiga juga merupakan angka 0 maka tahun itu adalah tahun kabisat lagi Inilah sebabnya mengapa 2000 adalah tahun kabisat tahun 1900 dan 2100 tidak Pemeriksaan ini harus saling bersarang, mencoba memasukkannya dalam satu JIKA tidak akan Work. Delimiters digunakan sebagai tujuan visual untuk sebuah pernyataan Mereka lakukan Perubahan nt tapi mereka membuat kode lebih mudah dibaca dan dipelihara Contoh pembatas adalah END-IF. Verbs yang memiliki pembatas akhir adalah kata kerja perbandingan IF, EVALUATE, input output READ, WRITE, DELETE, REWRITE, ACCEPT, matematika ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE, memproses transfer PERFORM, CALL dan beberapa kata kerja yang lebih rendah lainnya. Ketika kompilator menemukan periode yang dibutuhkan bahwa sebagai akhir dari pernyataan Pembatas yang ditemukan setelah suatu periode dalam kesalahan. Field adalah apa bahasa lain memanggil variabel Ini adalah tempat untuk menyimpan data Semua field harus dinyatakan dalam DIVISI DATA Deklarasi lapangan memiliki tiga bagian nomor tingkat nama field dan klausa klausa klausa PIC bersifat opsional. Nama field yang valid berasal dari Panjang 1 sampai 30 karakter hanya berisi huruf AZ, angka 0-9 dan tanda hubungnya berisi setidaknya satu huruf tidak dimulai atau diakhiri dengan tanda hubung dan bukan kata yang dicadangkan oleh COBOL. Ini adalah literal numerik khusus yang melekat pada COBOL HIGH - VALUES adalah COBOL yang setara dengan tak terhingga - tidak ada angka yang lebih besar dari pada HIGH-VALUES Sebaliknya, tidak ada angka yang kurang dari LOW-VALUES. Julian Dates. Julian adalah format tanggal yang merupakan alternatif untuk tanggal Gregorian Terdiri dari hari 3 digit dan Tahun tidak ada bulan Hari-hari mulai dari 1 Jan 1 sampai 365 atau 366 Des 31, tergantung pada apakah tahun itu adalah tahun kabisat atau tidak. Ini umumnya dikenal sebagai format dddyy atau dddyyyy, meskipun biasanya tanggal tersebut disimpan sebagai Yyddd atau yyyyddd untuk memudahkan dengan pemilahan. Layar yang menggunakan tanggal Julian akan memiliki rutinitas panggilan yang menyamarkan Julian ke Gregorian dan kembali lagi, karena manusia merasa nyaman dengan tanggal Gregorian. Fungsi tanggal intrinsik tersedia dengan kompiler COBOL yang baru memiliki konversi ini built-in. Julian format has two advantages First, it s smaller, so it takes up less space Second, it eases with some calculations because it contains no months For example, how many days are between Feb 5, 1997 and Nov 28, 1999 Convert to Julian 19970 36 and 1999332 a quick subtraction gives 1026 days Remember that borrowing a year gives you 365 days. Getting a future date or past date can also be easier with Julian What date is 45 days before Apr 15, 1999 Convert it to Julian 1999105 , subtract 45 to get 1999060 and convert back to Gregorian Mar 1, 1999.Level Numbers. Level numbers are used to group fields in the Data Division A field can then be defined as a collection of other fields The higher the level number the lower in the heirarchy the field is Normally, the field numbers 01, 05, 10, etc are used By spacing them out you leave yourself room in case a level needs to be added later Valid level numbers are 0-49.Each FD is required to have an 01-level field defined This is the record definition It can be broken down into smaller fields if desired For example. We have an 01-level field that is broken down into 4 fields the 05-level fields Two of the 05-level fields are also broken down Employee number is an elementary field because it is not broken down into smaller fields The employee name and birth date are group level fields because they are broken down into smaller fields Only elementary fields have PIC clauses. The birth date is 8 characters long the sum of the lengths of the elementary fields that compose it All 8 characters can be accessed with one name IN-BIRTH-DATE or one of its pieces can be accessed by using that name instead i e IN-BIRTH-MM. A group level item ends when another field with the same level number, or one with a lower value, is encountered For example, the list of fields within IN-BIRTH-YEAR ends when the 05-level IN-DEPARTMENT is encountered A field of level 10 would also have ended it. All group level fields are considered to be alphanumeric. All of these level number concepts are valid for WORKING-STORAGE also. Literals are specific values as opposed to fields Alphanumeric literals are enclosed in single quotes In the following statements.3 1415927 is a numeric literal and Enter a number is an alphanumeric literal COBOL has some built-in literals like ZEROES and SPACES. A paragraph is a section of COBOL code Paragraph names start in the A margin and follow the same naming rules that fields do A paragraph ends when another paragraph name is encountered Paragraphs can be executed with the PERFORM statement. You can think of a pargraph as the equivalent of a subroutine in other languages There are no arguments, all fields are thought of as global. PIC Clauses. PIC short for PICture clauses describe the size and type of data for each field Numeric data has a PIC character of 9, alphanumeric data uses X and alphabetic data an A Each 9, X or A represents one character Length can also be represented by a repetition factor The PIC clauses 9999 and 9 04 both define 4-digit numbers. The PIC character V is used to mark where a decimal point is If you had a 8-digit numeric field but 2 of the digits are after the decimal point, you would define it as PIC 9 06 V99 The decimal point is impl ied, it is not physically there in the data It also takes up no space To allow for a field to hold either positive or negative numbers precede the leftmost PIC character with an S PIC S999V99.There are several output PIC characters which help with formatting data for display or print Numeric fields are MOVEd to fields defined with these formatting PIC characters Fields defined with these formatting PIC characters are considered alphanumeric No calculations can be done with these fields Newer versions of COBOL allow these fields to be MOVEd to straight numeric fields. To print a decimal point place a in the desired place in the output PIC clause i e PIC 999 99 You can place commas in output numbers also i e PIC 999,999 99 In this manner the decimal point and commas do take up space These are considered insertion characters - they insert themselves into the data Other insertion characters are B for a space , 0 a zero and useful in printing dates. There is Z, for suppressing leading zeroes If the digit represented by a Z is a leading zero it will print as a blank You normally have one 9 in the PIC clause, in the one s place All other digits represented by Z s Do not use Z s after the decimal point If used with commas i e PIC ZZZ, ZZ9 99 a comma will only print if the character to its left prints, else it prints as a blank. There are other zero suppression characters A can be used just like the Z except that rightmost leading zero will print as a and all zeroes to the left of that will print as spaces So the value of 125 00 MOVEd to a PIC , 9 99 will print as 125 00 This behavior of the is called floating An will work the same way for check protection but all print, not just the one to the left of the most significant digit When either the floating or the is used in conjunction with commas the comma will only print as a comma if the character to its left prints as a digit Depending on the situation it will otherwise print as a blank, or. For sign control you can use or - as an output PIC character A will print for positive numbers and - for negative numbers A - will print a - for negative numbers and a blank for positive numbers Either can be repeated to suppress leading zeroes like the and can float also like the Alternatively, a or - can be placed to the right of the number. For accounting purposes the PIC characters DB and CR can also be used i e PIC , 9 99DB The DB or CR will only show if the value is negative If positive they will print blanks. Qualified Fields. It is legal in COBOL for different fields to have the same name These fields cannot be 01-level fields and cannot be part of the same group-level field. When referencing one of these fields the compiler requires the field to be qualified, meaning its group-level field must be specified If both INPUT-RECORD and OUTPUT-RECORD contained a field named PAY-RATE then in code you cannot simply reference PAY-RATE, it would have to either be PAY-RATE OF INPUT-RECORD or PAY-RATE OF OUTPUT-RECORD. Reference Modification. Reference modification allows for the referencing of a portion of a field without having to make it a group-level field and defining each portion of the field that will be accessed. If you wanted to check the value of the 4th through 6th characters of a field to see if they were equal to ABC you can code. The first number in the parenthesis represents the start position in the field and the second number represents the length Both values have to be specified COBOL treats all such references as alphanumeric. Since this is not a self-documenting feature it should not be used carelessly. A report is simply a formatted representation of data, suitable for being printed on paper hardcopy Reports generically look like. The first two lines are page headings, which will appear on every page The next printed line following the blank line is column headings It s common for column heading lines to be printed on every page Next come the detail lines - typically one per record At the end of the report will be a total line if you are totalling anything Note that the first detail line is the 6th line printed on a page must count the blank lines also. There are other types of lines that can appear on reports Sometimes there are page footings printed on the bottom of each page There can also be report headings and report footings only printed at the top and bottom of the report as opposed to each page. Note the formatting of the data There are commas and leading zeroes are suppressed on page numbers and monetary figures The date has slashes Always make reports as easy to read as possible. See the algorithms page for sample code. A section is a group of paragraphs The section name must begin in the A margin and be followed by the word SECTION Naming standards for sections are the same as those for paragraphs A section ends when a new one begins. A section can be PERFORMed in the same manner a paragraph is PERFORMed The PERFORM only uses the section name, there is no reference to i t actually being a section instead of a paragraph. Subscripts and Indexes. Subscripts and indexes are the two tools used to reference individual elements of a table A subscript is a working-storage field defined separately from the table and is completely available to the programmer An index is created automatically by the system if it is directed to do so and only has limited availability to the programmer. An index cannot be part of a calculation, cannot be MOVEd to another field or cannot receive another field from a MOVE and it cannot be DISPLAYed To manipulate an index the SET statement must be used. The major difference between a subscript and an index is that a subscript is a position in the table first element, 20th element, etc An index is a byte offset of an element relative to the beginning of the table Since the first element is 0 bytes away from the start of the table, it has an index of 0 The 20th element say each element is a PIC X 5 starts 95 bytes from the start of the tab le so its index is 95 When manipulating an index the programmer does not do so by this byte offset It is done by position in the table and the translation to byte offset is done internally by COBOL. See the algorithms page for sample code on loading and searching tables. Tables are the COBOL equivalent to arrays It is a set of fields with the same name and the same data type To reference an individual element of the table a subscript or index must be used. Tables are defined using the OCCURS clause. See the algorithms page for sample code on loading and searching tables. Truncation is a phenomenon that occurs when the receiving field of a MOVE or a math operation is not big enough to hold what it s getting For alphanumeric fields truncation happens on the right move COBOL to a PIC X 4 and you get COBO and numeric it happens on the left move 1000005 to a PIC 9 06 and you get 5 No warnings, no messages Just the loss of data.77-level Fields. A working storage field can be declared with a level number of 77 The 77 must be in column 8, the field cannot be a group-level field and the field cannot be part of a group-level field.88-level Fields. A field declared with a level number of 88 is commonly known as a condition name This name can be used anywhere a condition can be used and is generally more readable Condition names are declared immediately after the field they are associated with They use no storage they take up no room. For example your application contains a field named ACCT-TYPE which is PIC 999 One particular section of code determines if the account is a checking account account type 100, 110, 210 or 300 , a savings account type 150 or 175 or a CD IRA type 400 An IF statement could look like. Logically accurate but not entirely clear what account types are what Comments would help, but condition names will help more Define as. The same IF can now look like. Now it s self-documenting The added advantage is if another type of savings account is developed it only needs add ed at the condition name The IF statement doesn t change. A specific value can appear in multiple condition names Values associated with a condition name can be specified with THRU i e VALUES 90 THRU 99 When checking condition names NOT can be used If a condition name only has one value a statement such as SET CD-IRA-ACCT TO TRUE is valid and is the equivalent to MOVE 400 TO WS-ACCT-TYPE. The ACCEPT statement is used to get information from a source other than a data file like the keyboard or CPU clock. will cause the program to wait until the enter key is pressed Any data typed in before the enter key is pressed will then be placed in field See How do I for issues with getting numeric data in this manner See the algorithms page for sample code on receiving and processing data received interactively. The ACCEPT statement can also be used to get information from the system clock such as the current date and time. field-1 is PIC 9 6 The date will be in yymmdd format. field-2 is PIC 9 8 The tim e will be in hhmmsscc format where cc is hundredths of a second hh will be in military time 0-23.field-3 is PIC 9 3 The value will represent the current Julian date, which is a number from 1-366 representing the date as a number of days relative to the end of the previous year Jan 1st 1, Feb 1st 32, etc. field-4 is PIC 9 The values range from 1 Monday to 7 Sunday. The basic form of the ADD statement is. which adds value either a literal or a field to field-1 and stores the result in field-1 A list of fields can follow the TO which will add the value to each of them A list of values can be before the TO which would add all of them to field-1.It is possible to add two values either literals or fields and store the result in a separate field with the GIVING clause. Blank When Zero. BLANK WHEN ZERO can be specified with a PIC clause so that blanks are printed if the value of the field is zero For example, PIC -,--9 99 BLANK WHEN ZERO. The CALL statement is used to call another program As long as the called program contains a GOBACK or EXIT PROGRAM then when the called program finishes control returns to the calling program. Fields can be passed from the calling program to the called program These fields are in the calling program s WORKING-STORAGE SECTION and in the called program s LINKAGE SECTION The USING clause on the CALL specifies the fields to pass The called program lists these fields in the USING clause of the PROCEDURE DIVISION These fields don t have to have the same name in both programs, but the definitions must match. See the algorithms page for sample code on calling another program. The CLOSE statement will close an open file Attempting to close a closed file will produce a run-time error. One CLOSE statement can close multiple filesPUTE allows you to c ombine several math operations in one statement, using familiar symbols instead of English-like sentances. Expression is any valid mathematical expression involving literals fields and the following symbols COBOL has no recursion. Each of the examples can also be specified with a THRU option, allowing for a sequence of paragraphs to be executed. Paragraph-name-2 will also be executed. There is also what s known as an in-line perform where a block of code appears between a PERFORM and END-PERFORM No paragraph name is specified For example. When using the UNTIL option with a perform or in-line perform the UNTIL condition clause can be preceded by WITH TEST AFTER to have COBOL check the condition after the loop instead of before This will cause the loop to always be executed at least once This has the effect of a REPEAT-UNTIL loop of other languages. The read statement will read the next record from the specified file and place the data in the record layout of that file s FD The file must be al ready open as input Reading an unopend file or attempting to read beyond the end of a file will produce a run-time error The AT END clause is required. Optional clauses are NOT AT END and INTO NOT AT END specifies a statement to be executed if the read did not hit the end of the file INTO specifies a working-storage field into which the system will place the input record. The READ NEXT is used after a successful START to read records along the established access path The condition used by the START is not remembered by the READ NEXT so after each successful READ NEXT the record must be checked to see if it still matches whatever criteria the program is calling for A successful read only means that a record was retrieved. Since this is still a sequential process the READ NEXT requires an AT END clause The optional NOT AT END clause is supported. See the algortihms page for code examples. The REDEFINES clause allows you to have multiple field definitions for the same piece of storage The same data then can be referenced in multiple ways. Take a simple example, useful for data validation. This portion of the data division only consumes 8 bytes of storage, not 16 Each of the two PIC clauses is describing the same 8 bytes of data, just doing it differently. Once data is in WS-NUMBER-X it can be checked to see if it is numeric IF WS-NUMBER-X IS NUMERIC If so, WS-NUMBER can then be used as part of a calculation If the data happens to be non-numeric then this type of code will prevent the program from choking We access the data as alphanumeric any data allowed to see if it is safe to access it as numeric before actually attempting to do so. Note that once the data was moved to WS-NUMBER-X it was also moved to WS-NUMBER because they both describe the same portion of storage. There are a few rules with REDEFINES. A redefinition must have the same level number as the field it is redefining. The redefinition must immediately follow the field it is redefining i e if an 05-level field is bei ng redefined then the redefinition must be the next 05-level field. Cannot have a REDEFINES of an 01-level field in an FD. The redefinition should be the same size as the field it is redefining though not all compilers require this. It is possible to redefine at the group level though each group-level field does not have to the same number of elementary fields. Not all compilers allow VALUE with REDEFINES It s a bad idea in any case. Can have multiple REDEFINES of the same field. Back to Table of Contents. The RELEASE statment is required in an INPUT PROCEDURE of a SORT It is used to specify that a record is to be included in the sort. Only RELEASEd records will be sorted. See the algorithms page for sample code on using the SORT statement. The RETURN statment is required in an OUTPUT PROCEDURE of a SORT It is used to retrieve a record from the sort back into your program. The records are RETURNed in the sorted order. Like the READ statement the RETURN supports the NOT AT END and INTO optional cla uses Also like the READ, it is best if only one statement is used in either the AT END or NOT AT END clauses. See the algorithms page for sample code on the SORT statement. REWRITE will update the current record in a non-sequential file OPENed as I-O There must be a current record, so a successful READ or READ NEXT must precede the REWRITE Following the READ READ NEXT and before the REWRITE some information on the record will presumably be changed. REWRITE specifies the record, not the file. See the algorithms page for sample code on using non-sequential files. Rounded is a clause valid with any of the math verbs ADD SUBTRACT MULTIPLY DIVIDE COMPUTE Place it in the command after the name of the field that will receive the result. The search command is used to search a table for a particular entry The table must have an index see OCCURS The format is. The field is the field with the OCCURS clause WHEN specifies the condition on which to end the search usually when some field equals a table ent ry Only one statement can be specified in the WHEN but it can be a PERFORM The AT END clause is optional, specifying one statement to be executed if the entire table is searched without satisfying the WHEN condition It is recommended, however. There can be multiple WHENs but the search stops once the condition of a WHEN is satisfied To allow for multiple search matches use a PERFORM VARYING which can increment an index. If the table entries are sequenced by the field being searched then a binary search can be used instead Use SEARCH ALL instead of SEARCH It is more efficient than a regular search, especially with large tables The SEARCH ALL has some limitations. Only one WHEN is permitted. The WHEN condition can only test equality. The WHEN condition cannot contain an OR. The table field must be to the left of the in the condition. See the algorithms page for sample code on loading and searching tables. Set can be used to manipulate an index. Note that while an index is actually a byte offset w ithin a table COBOL does not expect you to work on that level Setting an index to 2 will cause it to point to the 2nd element in the table, regardless of its offset Likewise, seting an index up one will move it to the next element in the table, regardless of the size of the element COBOL will translate it to the proper offset for you. Set can also be used with condition names as an alternative to a MOVE Consider the following. It is then permissible to code. This is the equivalent to MOVE Y TO WS-END-OF-FILE-SW but it is more readable Most compilers will not allow a condition name with multiple values to be used in a SET It is not a good idea in any case. The sort statement is used to sort a file It requires a work file area that is defined in the FILE SECTION, just like any other file, except it is an SD instead of an FD The basic sort statement looks like. Multiple fields can be used in the sort, just list them in the desired order DESCENDING KEY can be specified instead of ASCENDING KEY DESCENDING KEY and ASCENDING KEY can be combined in the same statement. The SORT statement will open and close both the input and output files automatically The field s to be sorted on must be defined in the SD of the sort file. An INPUT PROCEDURE can be specified instead of an input file This allows the flexibility of selecting specific records to be sorted or to do other types of processing before the sort Likewise, an OUTPUT PROCEDURE can be used instead of an output file An INPUT PROCEDURE requires a RELEASE statement and an OUTPUT PROCEDURE requires a RETURN statement For example. This statement will execute paragraph-1 perform the sort and then execute paragraph-2 An INPUT PROCEDURE can be used with GIVING and an OUTPUT PROCEDURE can be used with USING Each of these options allows the THRU option i e paragraph-a THRU paragraph-b. The clause WITH DUPLICATES IN ORDER can be included in the statement after the last ASCENDING DESCENDING KEY This will cause any records with the same value s for the sort field s to be kept in their original order Not specifying this will not necessarily change their original order, but there is no guarantee. See the algorithms page for sample code on using the SORT statement. The Start statement is used to establish an access path for an indexed file with alternate keys see the algortihms page for code examples Note that keys in alternate indexes are not necessarily unique and the START is used in conjunction with the READ NEXT statement to find and retrieve and these records. The alternate key field must already be populated with a value. The first record in the file with that value for the alternate key is read It is a good idea to include a INVALID KEY clause in any START to handle the case where there is no record in the file with the appropriate alternate key. Instead of EQUALS the START also supports and NOT or NOT Back to Table of Contents. The stop run statement will cause a normal termination to your program. The STRING is used to con catenate join multiple fields or literals into one field It replaces a series of MOVEs For example. After the above statement is executed WS-DISPLAY-DATE will contain 12 24 2000 DELIMITED BY SPACE means to use as much of that field or literal that appears before the first space If there are no spaces like in the example then the entire field or literal is used Any character can be used in the DELIMITED BY clause. Literals are usually DELIMTED BY SIZE, meaning to use the whole thing. The DELIMITED BY character is never included in the combined field. The basic form of the subtract statement is. which subtracts value either a literal or a field from field-1 and stores the result in field-1 A list of fields can follow the FROM which will subtract the value from each of them A list of values can be before the FROM which would subtract all of them from field-1.It is possible to store the result in a separate field with the GIVING clause. The UNSTRING is used to split a field into multiple fields using a particular character to determine where to split the field For example. The above statement will take the all of WHOLE-NAME, up to but not including the 1st space, and place it into WS-FIRST The the part that is between the 1st and 2nd spaces, not including either one, is placed in WS-MIDDLE, and so on. USAGE can be used in conjunction with the PIC clause to specify how numeric data is to be stored The most common options are DISPLAY the default , COMP and COMP-3 COMP is short for COMPUTATIONAL, which can also be used The words USAGE IS are optional USAGE is only valid with numeric fields It can be specified as follows. A number stored as COMP is in binary format A COMP-3 number is stored as packed-decimal. The USING clause is used to pass parameters from one program to another It appears in the Call statement of the calling program to specify the parameter list These parameters must be working storage fields. The called program must have a USING clause on its PROCEDURE DIVISION sta tement followed by the parameters the program is receiving These fields are defined in the LINKAGE SECTION of the DATA DIVISION, which follows the WORKING-STORAGE SECTION All of the received fields are updateable by the called program. The parameters do not have to have the same names in the calling and called programs but the sizes and data types have to match. See the algorithms page for sample code on calling one program from another. Value allows you to initialize a field at the same time it is defined The VALUE clause follows the PIC clause and must be the proper type of data The value can be changed in code at any time. Some compilers will require the VALUE data to be the proper size also, others will truncate to fit Most compilers will not allow VALUEs in input FDs - it is a bad idea in any case. The write statement will write data to the specified file The file must be opened for output Attempting to write to an unopened file or a file opened for input will produce a run-time error. Optional clauses are FROM, BEFORE and AFTER FROM specifies a working-storage field from which the system will select the data that is to be written FROM can appear with either BEFORE or AFTER. BEFORE and AFTER specify actions to be taken by the printer along with writing a record of data You can either specify the number of lines that are to be advanced or you can specify advancing to the top of the next page BEFORE and AFTER cannot appear in the same write. This document will focus on a discussion of a numeric field or data string known as PACKED-DECIMAL format also referred to as packed data or a packed numeric field This format is used on an IBM Mainframe System and is supported by Micro Focus COBOL running on a Linux, UNIX or Windows System. Note The items in this document are appropriate for applications that are written in COBOL, Mainframe Assembler HLASM or PL I The IBM Mainframe architecture drove many of the numeric formats that existed in the early ANSI specifications for COBOL and have been carried forward to the current COBOL ANSI specifications. A packed decimal representation stores two decimal digits in one byte A packed decimal representation stores decimal digits in each nibble of a byte a byte is eight bits and a nibble is four bits Each byte has two nibbles, and each nibble is indicated by a hexadecimal digit For example, the value 23 would be stored in two nibbles, using the hexadecimal digits 2 and 3 the bit representation would be 0010 0011 The sign indication is dependent on your operating environment On an IBM mainframe, the sign is indicated by the last nibble of the last byte or high memory address For explicitly signed fields the C indicates a positive value and D indicates a negative value For unsigned or implied positive fields the F indicates a positive value. The mainframe can perform arithmetic functions on packed-decimal fields without having to convert the format Storing numeric values in a packed-decimal format may save a significant am ount of storage space For example, on the mainframe the value 12,345 would be five 5 bytes in length i e x F1F2F3F4F5 If the same information is stored in a packed-decimal i e USAGE IS COMPUTATIONAL-3 or abbreviated as COMP-3 the field would be three 3 bytes in length i e x 12345C. When converting records or data structures that contain this type of field from EBCDIC to ASCII the programmer is presented with a number of confusing options and challenges This document will try to explain the options and help the programmer avoid the common mistakes that are made during a conversion process. The following table shows the structure of a five digit numeric field using the Packed-Decimal format i e the COBOL syntax would be USAGE IS COMP-3 The field contains a value of one-hundred-twenty-three or 00123 Since the packed-decimal format stores a digit in each nibble 2 digits per byte the actual field size is only three 3 bytes. The Packed Decimal Format for a Numeric Field. Note-1 A field that is d efined as Unsigned i e PIC 99999 COMP-3 is an implied positive value Note-2 The Hex is an abbreviation for Hexadecimal notation Note-3 A field that is defined as Signed i e PIC S99999 COMP-3 will have the sign in the rightmost nibble of the units positions or Byte-2 in the preceding example A X nC is used as an explicit positive sign and a X nD is used as an explicit negative sign Note-4 The Packed-decimal format is the same for the Mainframe and for Micro Focus running on a Windows or UNIX system. We have made a significant effort to ensure the documents and software technologies are correct and accurate We reserve the right to make changes without notice at any time The function delivered in this version is based upon the enhancement requests from a specific group of users The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources. Copyright 1987-2017 SimoTime Technologies All Rights Reserved. Table, Packed-Decimal Field S izes. The following is a table that shows the actual field sizes for a COMP-3 or packed-decimal based on the number of digits specified in the picture clause. Convert Packed-Decimal to Text. This section describes how to convert the previously discussed packed-decimal formats into text strings to print or display the information in a human readable form Before converting the packed-decimal fields it should be determined if a conversion is necessary The following list provides some basic guidelines. When migrating an application both data and COBOL programs for processing the data from an IBM Mainframe System to a Windows System with Micro Focus Enterprise Server a conversion of the Packed-Decimal fields is not necessary Micro Focus COBOL supports the packed-decimal format. When migrating an application both data and COBOL programs for processing the data from an IBM Mainframe System to a Linux or UNIX System with Micro Focus Enterprise Server a conversion of the Packed-Decimal fields is not necessary Micro Focus COBOL supports the packed-decimal format. When migrating or transferring data from a COBOL oriented, IBM Mainframe or AS 400 environment to a non-COBOL oriented Linux, UNIX or Windows environment i e ASCII Text or excel spreadsheet then a conversion will be required This may require two conversion tasks The packed-decimal fields or data strings will need to be converted to a zoned-decimal format sign leading separate with an explicit decimal point should be considered depending on the target environment The zoned-decimal format may then require a conversion from EBCDIC to ASCII. When using the File Transfer Protocol FTP to transfer a data file between a Mainframe System and a Linux, UNIX or Windows System it will be necessary to use the BINARY mode if the records contain packed-decimal fields If a conversion between EBCDIC and ASCII is required it will need to be done after the file transfer. Convert to Text with Explicit Sign. This section describes how to convert a packed-decimal field i e PIC S9 5 USAGE IS COMPUTATIONAL-3 to a zoned-decimal field i e PIC S9 5 USAGE IS DISPLAY SIGN LEADING SEPARATE The resulting field will have a separate leading sign but will still have an implied decimal based on the field definition from the COBOL picture clause. Convert to Text with Explicit Decimal. This section describes how to convert a packed-decimal field i e PIC S9 5 USAGE IS COMPUTATIONAL-3 to a zoned-decimal field i e PIC X The resulting field will have a separate leading sign and an explicit decimal point embedded in the text string This field or data string may easily be exported to a non-COBOL environment. Spaces in a Packed Field. We have seen a few instances where a packed field may contain SPACES This should be considered a bad programming practice Having non-numeric values in a numeric field should be avoided The process that caused non-numeric values to be placed in a numeric field should be corrected When converting data between EBCDIC and ASCII this presents an additional effort to deal with the situation. A SPACE character hex 40 for EBCDIC or a hex 20 for ASCII could be a valid numeric entry in a packed field in all the positions of the field except the units positions It would be reasonable to assume that if the units position of a packed field is a SPACE character and all other positions are SPACE characters then the packed field SPACE values should be converted between EBCDIC and ASCII. For numeric fields with USAGE IS COMP-3 i e PACKED FIELDS the conversion code generated by SimoTime does not do any conversion This is the default behavior However, since the situation does exist the SimoTime technology has a configuration option to generate conversion code that will analyze a packed field and convert SPACE values between EBCDIC and ASCII or to initialize the packed field with a ZERO value. The following is sample code that will test a packed field for SPACE values and then convert the EBCDIC SPACE values to ASCII SPACE val ues. The following is sample code that will test a packed field for SPACE values and then initialize the packed field to ZERO values. When trying to do an arithmetic operation on a packed field that has a non-numeric value or an invalid sign the operation will ABEND with a S0C7 Program check on the Mainframe System The operation will ABEND with a 163 RTS error on a Micro Focus System. This condition is managed on the EBCDIC-encoded Mainframe System by using the NUMPROC NOPFD compiler option that accepts the invalid sign and treats space characters x 40 as zeroes This approach does not fix the problem, it simply tolerates the condition while presenting additional challenges for the data conversion and validation efforts. For files that contain records with packed or binary fields the EBCDIC to ASCII data conversion is done at the field level Since the packed and binary fields have their unique bit structure i e neither EBCDIC nor ASCII they are left in their existing structure Therefore, a packed field that contains all x 40 characters will contains all x 40 characters after the record is converted. Herein lies the challenge, the x 40 character is a space character on the EBCDIC-encoded Mainframe System but it is not a space character in an ASCII-configured environment. In an ASCII-configured Micro Focus environment the spaces in a numeric, packed field can be managed by using the SIGN-FIXUP compiler directive This directive provides limited emulation of NUMPROC NOPFD when used with HOSTNUMMOVE HOSTNUMCOMPARE. However, since the x 40 value is not a space character in the ASCII environment and is a valid numeric value in a packed field it will produce incorrect totals when used in an arithmetic operation Therefore, at a minimum the x 40 values will need to be changed to an ASCII space or x 20 character. Note the process that causes the packed fields to contain SPACE characters should be addressed The Compiler options only prevent the ABEND but may produce incorrect results wh en used in arithmetic processing. The following link will provide more details about compiler directives and numeric field processing. Explore the Compiler Directives available for the Micro Focus COBOL technologies. Explore how to process non-Numeric Values stored in a Packed-Decimal format This document will use examples to show how to manage a situation where non-numeric values such as Space Characters are placed in a Packed-Decimal field and then managed to avoid a S0C7 or RTS 163 error message and an abnormal termination of the program. The purpose of this document is to provide an overview of numeric data strings or fields that are packed-decimal format This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem This document and the links to other documents are intended to provide a greater awareness of the Data Management and Application Processing alternatives. The documentation and software were developed and tested on systems that are configured for a SimoTime environment based on the hardware, operating systems, user requirements and security requirements Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration. SimoTime Services has experience in moving or sharing data or application processing across a variety of systems For additional information about SimoTime Services or Technologies please send an e-mail to or call 415 883-6565 We appreciate hearing from you. Software Agreement and Disclaimer. Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the Simo Time copyright notice appear on all copies of the software The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies. SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose It is provided AS IS without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material. Downloads Links. This section includes links to documents with additional information that are beyond the scope and purpose of this document The fir st sub-section requires an internet connection, the second sub-section references locally available documents. Note A SimoTime License is required for the items to be made available on a local server. Current Server or Internet Access. The following links may be to the current server or to the Internet. Note The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the icon If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the icon. Explore how to process non-Numeric Values stored in a Packed-Decimal format This document will use examples to show how to manage a situation where non-numeric values such as Space Characters are placed in a Packed-Decimal field and then managed to avoid a S0C7 or RTS 163 error message and an abnormal termination of the program. Explore how to Calculate a Record Count and Accumulate Summary Totals by reading a Record Sequ ential Data File Each record contains numeric fields with a packed-decimal COMP-3 format The count and totals will be posted to the SYSOUT device. Explore The Binary or COMP format for numeric data strings This numeric structure is supported by COBOL and may be explicitly defined with the USAGE IS COMP or USAGE IS BINARY clause. Explore The Edited for Display format for numeric data strings This numeric structure is supported by COBOL and may be used with an edit-mask to prepare the presentation for readability by human beings. Explore The Packed-Decimal or COMP-3 format for numeric data strings This numeric structure is supported by COBOL and may be explicitly defined with the USAGE IS COMP-3 clause. Explore The Zoned-Decimal format for numeric data strings This numeric structure is the default numeric for COBOL and may be explicitly defined with the USAGE IS DISPLAY clause. Explore commonly used formats and processing techniques for managing various numeric formats available on the mainfr ame. Explore the Numbers Connection for additional information about the structure and processing of numeric data items or numeric fields. Explore the Compiler Directives available for the Micro Focus COBOL technologies. Explore How to Generate a Data File Convert Program using simple specification statements in a Process Control File PCF This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do the actual data file conversion The User Guide contains a list of the PCF statements that are used for the data file convert process. Explore How to Generate a Data File Compare, Validate or Hex-Dump Program using simple specification statements in a Process Control File PCF This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do a data file compare, accumulate summary totals with a record count or produce a Hex-Dump of records in a VSAM, KSDS based on a list of user-defined keys The User Guide contains a list of the PCF statements that are used for the data file compare, validate or dump process. Explore a typical data file conversion process that may be required when working in a multi-system environment This suite of documents describes a model for managing non-relational data structures Sequential Files and VSAM Data Sets that contain ASCII or EBCDIC text strings and various numeric formats such as BINARY, PACKED-Decimal and ZONED-Decimal This model has the capability of creating a test file for an ASCII or EBCDIC encoded environment This suite of documents will address many of the challenges of doing a record content conversion of a file that will be transferred between an EBCDIC-encoded Mainframe System and an ASCII-encoded Linux, UNIX or Windows System. Explore The ASCII and EBCDIC Translation Tables These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats. Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and or QSAM files. Internet Access Required. The following links will require an internet connect. A good place to start is The SimoTime Home Page for access to white papers, program examples and product information This link requires an Internet Connection. Explore The Micro Focus Web Site for more information about products and services available from Micro Focus This link requires an Internet Connection. Glossary of Terms. Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papersments or Feedback. This document was created and is copyrighted and maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please call or send an e-mail to. We appreciate hearing from youpany Overview. SimoTime Technologies was founded in 1987 and is a privately owned company We specialize in the creation and deployment of business applications using new or existing technologies and services We have a team of individuals that understand the broad range of technologies being used in today s environments Our customers include small businesses using Internet technologies to corporations using very large mainframe systems. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms. Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process SimoTime has the technology, servi ces and experience to assist in the application and data management tasks involved with doing business in a multi-system environment. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at. Packed-Decimal Format, Description and Discussion. Note 1 A binary field that is defined as Unsigned i e PIC 999 is an implied positive value A two 2 byte unsigned, binary field may contain a range of implied positive values from 0 to 65,535.Note 2 A binary field that is defined as Signed i e PIC S999 will use the high-order, leftmost bit as the sign A zero 0 is a positive sign and a one 1 is a negative sign A two 2 byte signed, binary field may contain a range of values from -32,767 to 32,767.The BINARY Format for a Numeric Field. We have made a significant effort to ensure the documents and software technologies are correct and accurate We reserve the right to make changes without n otice at any time The function delivered in this version is based upon the enhancement requests from a specific group of users The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources. Copyright 1987-2017 SimoTime Technologies All Rights Reserved. The Idiosyncrasies of COMP Fields. The creation and processing of COMP or BINARY data on a Windows or UNIX platform must be done in the same manner as the mainframe On the mainframe COMP or BINARY fields must be 2, 4, or 8 bytes in length the mainframe was originally a half-word, full-word and double-word centric system On Linux, UNIX or Windows using Micro Focus COBOL with Net Express or Server Express the COMP or BINARY fields may be 1 through 8 bytes in length. Note The syntax for COBOL is USAGE IS COMPUTATIONAL However, this is usually abbreviated to COMP or may be coded as BINARY. Notice the following, the record layout for the Item Master File contains two 2 COMP or BINARY fi elds These fields are defined as PIC 9 7 and may contain values from zero 0 through 9,999,999 or the binary values of x 000000 through x 98967F which may be contained in a three 3 byte binary field. Herein is the problem, on the EBCDIC-encoded, half-word, full-word, double-word, mainframe environment the fields would be allocated with an actual length of four 4 bytes for a binary field For the Micro Focus, ASCII-encoded, byte-oriented environment the fields would be allocated with an actual length of three 3 bytes for a binary field. The solution to this problem for the Micro Focus environment is to use the IBMCOMP and NOTRUNC directives when compiling the programs This will enforce the mainframe rules for COMP or BINARY fields and the field lengths will be the same as the mainframe. An alternative solution is to modify the copy file and change the PIC 9 7 to PIC 9 9 However, this solution requires a source code change and is not recommended during the first phase of a data migration. Nume ric Field Definitions Lengths. The following table shows the COBOL picture clause, the number of digits, the length of a packed field, the length of a binary COMP field for an IBM Mainframe and the length of a binary field for the Linux, UNIX and Windows LUW environments running Micro Focus COBOL. The differences in field or data string length are high-lighted in RED. It is important to note that Micro Focus Mainframe Express supports the mainframe format for binary or COMP fields This is accomplished by pre-setting the compiler directives to force this behavior The compiler directives are IBMCOMP and NOTRUNC These directives may also be used with Net Express and must be configured manually since the default for Net Express is to allow binary fields to be any length. Big Endian Little Endian. Information is usually process by executing programs that were created using a program language that separates the user programmer from the underlying hardware structure However, this separation is not one-hundred percent Therefore, some level of awareness or understanding of the hardware may be required The hardware techniques used to define, process, save and retrieve numeric values is typically an area where some level of understanding is required. First, lets review how units of information are structured in a typical computer system. A bit is a unit of information A bit may be in an OFF or ON condition that is traditionally referred to as 0 or 1 Four 4 bits make a nybble and eight bits or 2 nybbles make a byte. Note The term nibble is commonly used but the original spelling was nybble. Next, lets review how units of information are stored in memory and processed by the system. In order to understand the concept of Big and Little Endian we need to understand memory typically referred to as RAM or Random Access Memory We may think of RAM as one large array with many one-byte elements An Index is typically used to access a specific element within an array An Address is typically used t o access a specific location within RAM or memory. Note For this discussion we are using a RAM architecture that stores one byte in each RAM location There are some RAM architectures where each memory location stores something besides a byte However, these are rare so we will limit this discussion to RAM architectures that are byte oriented. An IBM Mainframe System has the hardware capability of performing arithmetic tasks using a variety of different formats Since we are currently focused on a discussion of Big and Little Endian formats we will limit this discussion to 32 bit or 4 byte integers For COBOL programmers this would be USAGE IS COMPUTATIONAL. The question, How are these 4 bytes placed in RAM for processing. The answer, It depends, The IBM Mainframe System uses Big Endian and the hardware that is used to run Linux, UNIX and Windows typically use Little Endian It would be important to note that Micro Focus COBOL has a compiler directives IBMCOMP that provides support for the Big Endian support for COMP fields. The following shows how the 4 bytes of a 32 bit integer are arranged in RAM starting at an address location of 100.Note Notice the bytes of the little endian are in the reverse order when compared to big endian format With little endian the least significant byte is stored first With big endian the most significant byte is stored first. Next, lets review how data files are used to save and retrieve units of information. To understand the importance of endianness lets take a look at the following example. A data string of x 1A2B3C4D is written to a file on a system that uses big endian. This is hexadecimal notation of four bytes 1A, 2B, 3C and 4D or 32 bits 0001 1010 0010 1011 0011 1100 0100 1101.On a Little Endian System this would represent a decimal numeric value of 1,295,788,826.Attention This would result in a difference of 856,747,725 between the expected value and the actual value. The purpose of this document is to provide an overview of binary formats for numeric data strings or fields This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem This document and the links to other documents are intended to provide a greater awareness of the Data Management and Application Processing alternatives. The documentation and software were developed and tested on systems that are configured for a SimoTime environment based on the hardware, operating systems, user requirements and security requirements Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration. SimoTime Services has experience in moving or sharing data or application processing across a variety of systems For additional information about SimoTime Services or Technologies please send an e-mail to or call 415 883-6565 We appreciate hearing from you. Software Agreement and Disclai mer. Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies. SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose It is provided AS IS without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement SimoTime Technologies shall not be liable for any direct, indirect, special or con sequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material. Downloads Links. This section includes links to documents with additional information that are beyond the scope and purpose of this document The first sub-section requires an internet connection, the second sub-section references locally available documents. Note A SimoTime License is required for the items to be made available on a local server. Current Server or Internet Access. The following links may be to the current server or to the Internet. Note The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the icon If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the icon. Explore The Binary or COMP format for numeric data st rings This numeric structure is supported by COBOL and may be explicitly defined with the USAGE IS COMP or USAGE IS BINARY clause. Explore The Edited for Display format for numeric data strings This numeric structure is supported by COBOL and may be used with an edit-mask to prepare the presentation for readability by human beings. Explore The Packed-Decimal or COMP-3 format for numeric data strings This numeric structure is supported by COBOL and may be explicitly defined with the USAGE IS COMP-3 clause. Explore The Zoned-Decimal format for numeric data strings This numeric structure is the default numeric for COBOL and may be explicitly defined with the USAGE IS DISPLAY clause. Explore commonly used formats and processing techniques for managing various numeric formats available on the mainframe. Explore the Numbers Connection for additional information about the structure and processing of numeric data items or numeric fields. Explore How to Generate a Data File Convert Program using simp le specification statements in a Process Control File PCF This link to the User Guide includes the information necessary to create a Process Control File and generate the COBOL programs that will do the actual data file conversion The User Guide contains a list of the PCF statements that are used for the data file convert process. Explore a typical data file conversion process that may be required when working in a multi-system environment This suite of documents describes a model for managing non-relational data structures Sequential Files and VSAM Data Sets that contain ASCII or EBCDIC text strings and various numeric formats such as BINARY, PACKED-Decimal and ZONED-Decimal This model has the capability of creating a test file for an ASCII or EBCDIC encoded environment This suite of documents will address many of the challenges of doing a record content conversion of a file that will be transferred between an EBCDIC-encoded Mainframe System and an ASCII-encoded Linux, UNIX or Windows System. Explore The ASCII and EBCDIC Translation Tables These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats. Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and or QSAM files. Internet Access Required. The following links will require an internet connect. A good place to start is The SimoTime Home Page for access to white papers, program examples and product information This link requires an Internet Connection. Explore The Micro Focus Web Site for more information about products and services available from Micro Focus This link requires an Internet Connection. Glossary of Terms. Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papersments or Feedback. This document was created and is copyrighted and maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please call or send a n e-mail to. We appreciate hearing from youpany Overview. SimoTime Technologies was founded in 1987 and is a privately owned company We specialize in the creation and deployment of business applications using new or existing technologies and services We have a team of individuals that understand the broad range of technologies being used in today s environments Our customers include small businesses using Internet technologies to corporations using very large mainframe systems. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms. Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform The da ta will need to be transferred between the systems and may need to be converted and validated at various stages within the process SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at. Binary or COMP Format, a Description and Discussion.

Comments