B34A1010 - Flat File Operations

Zoltan_Gyimesi

Zoltan_Gyimesi

Legendary Poster
Hi Forum/List,

B34A1010 BSFN "Flat File Operations" Source Modul contains 3 Business Functions (B7332 and later) as "Open Flat File", "Close Flat File" and "Write One Line To Flat File".

The attachment of the Close and Write functions contain the following in their Purpose section:
"...file that has been opened by Flat File Operations – Open File (in the same source)."

Now I would like (very much) to know exactly the scope this three related functions, punctually what does it mean "in the same source" exactly in the case of an APPL and UBE? (e.g. Same event; same control or "event owner"; same section/form; same APPL/UBE; what about Form/Report interconnect and embedded BSFN calls, etc.)

Any input, shared experience will be welcome and appreciated!

Thanks in advance,
Zoltán

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Zoltan,
I've just completed a project using the B34A1010 business function. I used the function within a report UBE.

I used the 'Open' in my report level break header section.
I used the 'Write' in my main process DO section.
I used the 'Close' in my main process END section.

It worked perfectly fine. Any more questions...please ask. I'll check again over the weekend.

K
 
Hi "karenet",

Thank you very much your input. I am glad to know that these operations aren't limited into a single event.

The further scenarios could be interesting also:

R1, R2, R3 are UBEs (or APPLs)
B1, B2 are BSFNs

A. Scenario:
============
Open in R1
R1 call R2
Write in R2 and R2 returns
Close in R1

B. Scenario:
============
Open in R1
R1 call B1
Write in B1
Close in R1

C. Scenario:
============
Open in B1
B1 call B2
Write in B2
Close in B1

D. Scenario:
============
Open in R1 and R1 returns
Run R2 and Write in R2 and R2 returns
Run R3 and Close in R3

... and many other combinations.

A and B scenarios are really real situations.
The main point is that can the operations used in stacked calls (APPL/UBE/BSFN) and separated calls (APPL/UBE/BSFN). Of course, always passing the FilePtr.

If I will ever enough time I will test it.
Maybe somebody already used or tried to use one of the above scenarios and will share her/his experiences sparing time for us.

"karenet", thanks again.

Zoltán



B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Hi guys,

I too have questions about the B34A1010 (Flat File Operations).
I wish to write data from inside a UBE to a flat file. Sounds
simple right ? ... Any / all help or advice is welcome. Here's
what I'm doing :

I'm in the DO Section of the ER. I click on the Business Functions
button, i.e, the red F(X). I type in 'B34A1010' on the QBE line for
column 'Source Module', click on Find. I choose Function Name
'OpenFlatFile'. I then click on 'szFilePath', click on 'Literal'
and enter the name of the file where I want to put my data.
I click on OK. I get the following error message :

"Cannot exit until all required item fields are mapped to an
available object."

I noticed that Data Structure Item 'idFilePtr' is red. Ah ha!
I click on 'idFilePtr'. There are no available objects for this
item! The left side of the Data Structure becomes empty when
I click on 'idFilePtr'. What do I do from here ? How can I create
a idFilePtr variable ?

Any ideas ?

Jim.

OW B7332 SP10.1
 
From the menu select "Section" and scroll down to "Database Output". The
wizard will walk you through writing a "comma delimited" output file. This
is a quick and easy way to get flat file output from a UBE.



Neil G. Norman
Alcon Labs - Fort Worth, Texas
817.615.5020
 
Jim,

The "idFilePtr" variable is from alias GENLNG, a variable of type 7 (identifier). Actualy any variable of type 7 should do the job, but this one (GENLNG) is perfect for this use.

The "idFilePtr" variable is a pointer to the flat file. Since you can open flat file in one section and close it into another section then it's normaly a "report" variable. This "idFilePtr" keep note of the file location and you refer to it when you need to access the file. If you ever have the situation where 2 flat file output are required at the same time then you need to use 2 different pointer.

It is important that you remember to close the file pointer if you want to avoid memory crash.

Here is a common use for thoses pointers :

Let's say that your report have one section only to display the information. then take a look at this code that I did at a client:

*******************************************************************
GLOBALS: Global Variable
*******************************************************************
rpt_idFilePointer_GENLNG
rpt_cFileOpenError_EV01
rpt_szFileOpenErrorCode_GS1A
rpt_cComma_EV01

------------------------------------------------------------------
EVENT: Initialize Section
------------------------------------------------------------------
VA rpt_cComma_EV01 = ","
If PO cEraseFlatFileFirst is equal to "1"
Open Flat File
"<Blank>" -> cSuppressErrorMessage
VA rpt_cFileOpenError_EV01 <- cErrorCode
VA rpt_szFileOpenErrorCode_GS1A <- szErrorMessageId
"<Blank>" -> cAppendMode
VA rpt_idFilePointer_GENLNG <- idFilePtr
PO szFlatFileName -> szFilePath
Else
Open Flat File
"<Blank>" -> cSuppressErrorMessage
VA rpt_cFileOpenError_EV01 <- cErrorCode
VA rpt_szFileOpenErrorCode_GS1A <- szErrorMessageId
"1" -> cAppendMode
VA rpt_idFilePointer_GENLNG <- idFilePtr
PO szFlatFileName -> szFilePath
End If
If VA rpt_cFileOpenError_EV01 is equal to "1"
// Error Should take place here
End If

------------------------------------------------------------------
EVENT: Do Section
------------------------------------------------------------------
evt_szTempBatchNumber_AA25
evt_szTempOrderNumber_AA25

//Convert values to string
VA evt_szTempOrderNumber_AA25 = [RV Order Number]
VA evt_szTempBatchNumber_AA25 = [RV BatchNumber]

//
VA evt_szOutputString_D200 = concat([VA evt_szTempBatchNumber_AA25],[VA rpt_cComma_EV01])
VA evt_szOutputString_D200 = concat([VA evt_szOutputString_D200],[VA evt_szTempOrderNumber_AA25])
//
If VA rpt_cFileOpenError_EV01 is not equal to "1"
Write One Line To Flat File
"<Blank>" -> cSuppressErrorMessage
VA evt_cFileWriteError_EV01 <- cErrorCode
VA evt_szFileWriteErrorCode_GS1A <- szErrorMessageId
VA rpt_idFilePointer_GENLNG -> idFilePtr
VA evt_szOutputString_D200 -> szRecord
If VA evt_cFileWriteError_EV01 is equal to "1"
// Error Handling should take place here
End If
End If
-------------------------------------------------------------------
EVENT: End Section
-------------------------------------------------------------------
evt_cFileCloseError
evt_szFileCloseErrorCode
If VA rpt_cFileOpenError_EV01 is not equal to "1"
Close Flat File
"<Blank>" -> cSuppressErrorMessage
VA evt_cFileCloseError <- cErrorCode
VA evt_szFileCloseErrorCode <- szErrorMessageId
VA rpt_idFilePointer_GENLNG -> idFilePtr
End If

OK, this is just part of my code, but you should have everything you need to write to the flat file.

I hope that this will help.

Christian Audet






Implementing B7333 (Xe) SP14.1, SQL
(Support B732, B7331 and B7332)
 
Jim,

I you are wondering where this "file pointer" logic is coming from in OneWorld then the answer is : "it's all coming from C language" !

Since I know all the C structure, that's why I can give you a good explanation about pointer.

I hope to help you again Jim.

Christian

Implementing B7333 (Xe) SP14.1, SQL
(Support B732, B7331 and B7332)
 
Back
Top