Reading Dynamic Flat Files

Larry_Jones

Larry_Jones

Legendary Poster
Chris,

Here is how I implemented a 'ReadTextLine' function as originally described by Zoltan.

1. In OMW Copy Data Structures D34A1010A,B,C to D55A1010A,B,C
2. Create New Data Structure - D55A1010D as follows:
cSuppressErrorMessage Suppress ErrorMessage ->
cErrorCode ErrorCode <-
szErrorMessageId DataItem <-
idFilePtr GenericLong ->
szRecord VariableLengthField1 <-
2. in OMW create a new BSFN - call it B55A1010 - that mirrors B34A1010:
- Function Names almost same as in B34A1010 but change 'Flat' to 'Text' (you may want to append '55' also)
- New Function - ReadTextLine
- uses above new Data structures for functions
3. Edit BSFN B55A1010 source - copying code from B34A101.c and .h and changing as appropriate to new function names, etc. Add Code for new function - ReadRextLine.

See attached source code for B55A1010.c and .h

Regards,
Larry

<original Post shown below>
----------------------------------------------------------------------
I was most interested is in a some postings on JDELIST by yourself and Zoltan Gyimesi.
They listed under 'Raading Dynamic Flat Files' and discussed the addition of a 'ReadNextLine' function to B34A1010.

We have long wanted to input text files 'line by line' into our own UBE's, but have found no simple standard JDE solution.
We currently have to endure the inconvenience and limitations of Table
Conversion.

Being a absolute novice C programmer, and being totally unfamiliar with JDE C conventions, I was hoping you might be able give us some pointers as to how to implement 'ReadNextLine'.

It seems to me that the existing 'OpenFlatFile' would need a new option to open in Read Mode. Could the new 'ReadNextLine' be based on the existing 'WriteOneLine', basically by using 'fscanf' in place of 'fprintf' ? Would a new data structure be needed in the header file ?

Did you end up copying B34A1010 into the user name range (eg B55A1010) and modifying that copy ?
If so, did you have to change the existing Business Function names in that copy (eg WriteOneLine) to be unique ?

Would you recommend that the new program only be used for 'OpenForInput' and 'ReadNextLine', while B34A1010 continue to be used for 'WiteOneLine' and 'CloseFlatFile' ?

Any advice and warnings you may care to provide would be most appreciated.
__________ __________ __________ __________ ______
Chris Vaughan Phone: 03 8603 1458 (BH)
ICT Applications Architecture 0409 199 735 (M)
PWC BPO Holdings Australia 03 8603 1482 (FX)

Larry Jones
[email protected]
OneWorld XE, SP 15.1
HPUX 11, Oracle SE 8.1.6
Mfg, Distribution, Financials
 

Attachments

  • 3-30725-B55A1010.zip
    3.5 KB · Views: 400
Larry,
We now have something that we have needed for a long time.
Your assistance and advice greatly exceeded what we might have reasonably expected. Many many thanks.
 
Hello,
This is a useful BFSN for Flat File !!!
 

Attachments

  • 3-30926-ManipulateFlatFile.zip
    2.9 KB · Views: 327
Another question on the ReadTextLine function. Apologies to Larry if he has sent me a reply to this question i mailed him direct - our mail was down for 24 hours and we lost all incoming mail.

Anyway the problem i have is as follows:

(i am not familiar with creating C bsfns except generated as NERs so apologies if i've done something basic wrong)

I followed Larrys instructions as per the original thread :

- Copied existing data structures D341010 A -C
- Created New Data structure D55A1010D as per instructions
- Created new BSFN B55A1010 and changed names to Text and added new function Read Text Line
- Copied the .C and .H files from Larrys attachment to the spec and include dirs in the DV7333 pathcode.
- Generated bsfns

I have created a dummy UBE to read the contents of a text file on root C. I have set up the code in the INIT event as a quick test as follows:

-----------------------------------------------------------------------
0001 //
0002 VA rpt_cSUPPS_SuppressErrorMssage = "1"
0003 VA rpt_szVAR1_FilePath = "C:\test.txt"
0004 //
0005 Open Text File
"1" -> cSuppressErrorMessage
UNDEFINED <- cErrorCode
VA rpt_szDTAI_DataItem <- szErrorMessageId
UNDEFINED -> cAppendMode
VA rpt_sz_GENLNG_GenericLong <- idFilePtr
VA rpt_szVAR1_FilePath -> szFilePath
0006 //
0007 Read Text File Line
VA rpt_cSUPPS_SuppressErrorMssage -> cSuppressErrorMessage
VA rpt_cERRC_ErrorCode <- cErrorCode
VA rpt_szDTAI_DataItem <- szErrorMessageIdDataItem
VA rpt_sz_GENLNG_GenericLong -> idFilePtrGenericLong
VA rpt_szVAR1_VariableField1 <- szRecordVariableLengthField1
0008 //
0009 RV Variable Length Field 1 = VA rpt_szVAR1_VariableField1
0010 //
0011 Close Text File
VA rpt_cSUPPS_SuppressErrorMssage -> cSuppressErrorMessage
VA rpt_cERRC_ErrorCode <- cErrorCode
VA rpt_szDTAI_DataItem <- szErrorMessageId
VA rpt_sz_GENLNG_GenericLong -> idFilePtr

What I am finding is that the first Open Text file fails with a return code of:


VA rpt_szDTAI_DataItem = 078

It appears the Open text file cannot retrieve the file to open it - however, if i change this to the OpenFlat file business function it find the file ok. This indicates that I have not created the BSFNs corectly.

I have checked all the data structures and they appear correct and all the BUSBUILD generation completed succesfully. The BSFN appears to pciking up the correct source as wel so I am at a loss as to what i have done wrong.

Does anyone have any clues?

thanks

dave


OW XE base sp18.1 oracle NT
 
Dave,

yes I did message you - once by email and once via this forum. Oh well.
Here was my reply:

Took a brief look at your code - the thing that jumps out right away is that you are not supplying some arguments to the BSFN.

One critical argument is in the Open - the "AppendMode" argument. Without that the file will not be opened. You must specify either "A" - Open a file for appending (writing) new data to the end of the file (if file does not exist it will be created), "W" - Create a new file for writing to, or "R" open an existing file for reading from.

I would also strongly suggest you supply a variable for the cErrorCode value - I notice use use one in the ReadText function.

Regards,
 
Re: Sequence Flat File

Hello all,
I am using a Process where I need to populate the Time Analysis table from a flat file which comes from a Third Party product. Can anyone tell me how can I sequence the data in the Falt File which is the Input File in the TC so that the output tables are populated faster. Right now I have to Populate a Custom Table and then use that table in another TC inroder to get the sequenced data. The number of records in one exercise counts to upto a million.
 
RE: Sequence Flat File

Hi
I hopw this process will work for U

1) Open the Txt file in EXCEL and sort the COLS
2) Save the CSV file as TXT]
3 Use the TXT as a input to TC
Regards,
 
Hi Larry,
I followed your instructions as far as creating the data stuctures and the BSFN, I've generated the BSFN on CDBASE (Parent DLL). I've created a UBE that uses the Open and Read statements but when the UBE runs (Local) gives me the following OWError:
"Business Funtion Load Failed - CDBASE - _Open Flat@12"

Do you have any idea what am I doing wrong?
Any advice would be greatly appretiated.

JS
 
Jerry,

1. Although I don't think this is your problem, you should never assign custom DLLs to standard JDE Libraries/DLLs - for reasons that have been discussed on this forum. Instead use your own, custom library.

2. Is it safe to assume the failure is occurring on the same PC where you created and compiled/linked the BSFN?

3. Other than #1 above I don't know what you did wrong. Can you post (zipped):
a) a snapshot of the Business Function Design Screen (W9862H) for your BSFN
b) A screen snaphot of the Datastructure used by the Open function
c) Your BSFN .c and .h source code.

Regards,
 
Hi Jerry and Larry,

Larry is right as usual :)

Always place your custom BSFN into a custom DLL instead of into any DLL which originally exists in OneWorld.

Other question:

Was the BSFN Build TOTALLY successfull without restoring the previous state of the DLL?

Here is my practice when I build or re-build BSFN:

1.) I close all application except Object Librarian / Object Management Workbench.

Reason: the DLL can be locked by an open application.

2.) I exit and re-enter OW after building and before testing the BSFN.

Reason: the old version can be cached in the memory and the test won't see the changes.

Hope, this helps a bit

Regards,

Zoltán

P.S.: Larry, Thank you that you have mentioned my name - that I shared originally this Flat File operation on JDEList Forum.
 
Hello,

I have copied the BSFN B34A1010 and modified it to read a line from a text file - with thankx to Larry/Zoltan who's code I have used to do this!

There were no warnings or errors while building the BSFN and I have put it in the CCUSTOM DLL (DLL has been re-build as well).
I have created and used a new NER before, and this worked fine.
This BSFN, however, won't work - whenever I make a call to this BSFN, I get the following error message:

'Business Function Load Failed - CCUSTOM - _OpenFlatFileCustom@12'

The BSFN has not been deployed yet, but I suppose it should work locally on my pc. Can anyone help me om this one?

Bye,

Sofie Hönen

Win2000 Service Pack 2 (VER_PLATFORM_WIN32_NT 5.0)
082004:0200_OneWorld_ERP9.0_SP2_S1
 
Hi Sofie,

Q1.) Have you done it on a Fat Client?
Q2.) Did you developed the BSFN and tested it on the same workstation on the same Path Code?

I suppose, you logged out E1 and logged in again, am I right?

1.) To be sure, that DLL will be refreshed in system memory, re-boot your workstation and try it again.
2.) If it does not solve the problem, log out E1, delete the well known 6 spec file and try again.
3.) If it still does not solve the problem, then Check-In the objects and try again (maybe repeat the steps from #1)

Pleas, let us know you results. Thanks.

Good luck,

Zoltán
 
In busbuild, you need to run linkall, so it relinks the BSFN to the correct dll.
 
Hello Zoltán,

Thanks for your reply!

My answers to your questions are as follows:
Q1.) Have you done it on a Fat Client? => Yes
Q2.) Did you developed the BSFN and tested it on the same workstation on the same Path Code? => Yes
I suppose, you logged out E1 and logged in again, am I right? => Yes

I have followed your 3 recommendations, but unfortunately the result is still te same; I still get the error message when calling the BSFN....

Bye,

Sofie
 
Hi Sofie,

Please, check the date/time stamp and file size of CCUSTOM.DLL, that does it differ from the previous state (e.g. against an instance on an other workstation or on deployment server.

Have you built the BSFN under OMW in E1 with "Build Business Function"?

Maybe you can try to rebuild the whole DLL outside of E1 with BusBuild.

Read you later,

Zoltán
 
Hello Zoltán,

I have tried all your suggestions... still not working...

Sofie
 
Hi Sofie,

Have you ever changed the host DLL of the BSFN?

Yes or no, try to re-enter the BSFN call in the APPL/UBE and test it again.

Read you later,

Zoltán
 
Hi Zoltán,

I initially created the BSFN in the CCUSTOM DLL, so I have never changed the DLL. I just re-entered the call to the BSFN in my batchjob (just to try), but it still does not work.

I also tried to copy a very straight forward standard BSFN to a new BSFN (made a new BSFN, copied the C-files and changed all the necessary references), and guess what... this BSFN gives the same error message.... this makes me think that in one way or the other I am just not able to create & use new C BSFNs on this system... but why? This is the first time I'm working with ERP8.0 - might there be a special trick in this release to make BSFNs work?

Bye again,

Sofie
 
Hi Sofie,

Very sorry. I am out of idea :-(
What does it mean ERP8 exactly (I am confused on new naming convention)? Is it B9 or 8.9?

Going ahead trying to solve this isse, I suggest:
1.) Try all on an other fat client.
2.) Make ressearch on the PSFT Solution Search and SAR Search.
3.) Post your issue onto the Technical forum too. Maybe there are more expert there, because it seems so, it can be a CNC or techhnical issue.

Please, keep us inform anyway. Thanks.

Good luck again,

Zoltán
 
Is this the first time you've put something into CCUSTOM.DLL? If you've
never used it before, I'm pretty sure there is a KG document that tells you
what you need to do to generate CCUSTOM.DLL the first time.
 
Back
Top