Fetch Next Line From Flat File(B76B0220)

Amith

Amith

Active Member
I am using a Business Function B76B0220(Fetch Next Line From Flat File) & some other BSFN to get the data from text file and insert it in JDE table.

It is working fine for one line and the data is inserted into table also.but it is not going to the next line to fetch next line.

I have a doubt with idFilePtr and generic long(GENLNG).
can anyone explain about these and the solution for this problem
 
Hello Amith,

The idFilePtr parameter is a Flat File pointer. The first time you call "Fetch Next Line From Flat File" the output value will be not equal to zero.
You have to hold this value and asign it again to idFilePtr parameter the second time you call "Fetch Next Line From Flat File".
idFilePtr will always return a number not equal to zero until the BSFN reach EOF. Then idFilePtr will be zero.

Try this:

Fetch Next Line From Flat File (asign a VA to idFilePtr)
While VA not equal to Zero
.
.
.
Table.Insert
Fetch Next Line From Flat File (asign a VA to idFilePtr)
End While

Hope this help you,



Luis.
 
**NOTE**:Source and Destination path is given from Processing Option and thre is no business view added to the report*****

***********************************************************************
GLOBALS: Variables (Global)
***********************************************************************
rpt_UserId_USER
rpt_DateUpdated_UPMJ
rpt_TimeOfDay_TDAY
rpt_WorkStationId_JOBN
rpt_GenericLong_GENLNG
rpt_Description_DESCR
rpt_ErrorCode_ERRC
rpt_ErrorDescription_ERRDSCA
rpt_EdiUserId_EDUS
rpt_EdiBatchNumber_EDBT
rpt_EdiLineNumber_EDLN
rpt_EdiSuccessfullyProces_EDSP
rpt_TransactionAction_TNAC
rpt_EdiTransactNumber_EDTN
rpt_Description_DSCRP5
rpt_FromPath_PTH
rpt_FileName_PTH
rpt_LengthFrmPth_MATH01
rpt_PathLength_MATH01
rpt_Counter_MATH01
rpt_CurrentChar_EV01
rpt_AddressNumber_AN8
rpt_CurrencyCodeAP_CRRP
rpt_PaymentTermAP_TRAP
rpt_PaymentInstrument_PYIN
rpt_TaxExpCod2_EXR2
rpt_TaxArea2_TXA2
rpt_CurencyCodeAB_CRCA
rpt_Path_Destination_PTH
rpt_StringDate_DESC

=======================================================================
SECTION: DriverSection [GROUP SECTION] ()
=======================================================================
OBJECT: SECTION
EVENT: Initialize Section
-----------------------------------------------------------------------
OPT: Using Defaults
//
// Get Audit Information
//
Get Audit Information
VA rpt_UserId_USER <- BF szUserName
VA rpt_DateUpdated_UPMJ <- BF jdDate
VA rpt_TimeOfDay_TDAY <- BF mnTime
VA rpt_WorkStationId_JOBN <- BF szWorkstation_UserId
//
PO szFromPath = rtrim(ltrim([PO szFromPath]," ")," ")
//
// Breaking Source Path and File Name
VA rpt_Counter_MATH01 = "0"
VA rpt_LengthFrmPth_MATH01 = "0"
VA rpt_PathLength_MATH01 = "0"
VA rpt_LengthFrmPth_MATH01 = length(ltrim(rtrim([PO szFromPath]," ")," "))
VA rpt_Counter_MATH01 = [VA rpt_LengthFrmPth_MATH01]-1
//
// Get File Name
While VA rpt_Counter_MATH01 is greater than <Zero> And VA rpt_CurrentChar_EV01 is not equal to "\"
//
VA rpt_CurrentChar_EV01 = substr([PO szFromPath],[VA rpt_Counter_MATH01],([VA rpt_Counter_MATH01]+1))
VA rpt_Counter_MATH01 = [VA rpt_Counter_MATH01]-1
//
End While
//
VA rpt_Counter_MATH01 = [VA rpt_Counter_MATH01]+1
VA rpt_FileName_PTH = substr([PO szFromPath],([VA rpt_Counter_MATH01]+1),(([VA rpt_LengthFrmPth_MATH01]-[VA rpt_Counter_MATH01])+1))
VA rpt_FromPath_PTH = substr([PO szFromPath],0,[VA rpt_Counter_MATH01])
//


//
Fetch Next Line from Flat File
PO szFromPath -> BF szFlatFileName
VA rpt_GenericLong_GENLNG <> BF idFilePtr
VA rpt_Description_DESCR <- BF szFlatFileRecord
"2000" -> BF mnRecordLength
VA rpt_ErrorCode_ERRC <- BF cErrorCode
VA rpt_ErrorDescription_ERRDSCA <- BF szErrorMessageID
//
While VA rpt_GenericLong_GENLNG is greater than <Zero>
//
VA rpt_CurrencyCodeAP_CRRP = " "
VA rpt_TaxArea2_TXA2 = " "
VA rpt_TaxExpCod2_EXR2 = " "
VA rpt_PaymentTermAP_TRAP = " "
VA rpt_PaymentInstrument_PYIN = " "
VA rpt_CurencyCodeAB_CRCA = " "
//
// GET CRRP SEGMENT 0
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
<Zero> -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_CurrencyCodeAP_CRRP = substr([VA rpt_Description_DSCRP5],0,3)
VA rpt_Description_DSCRP5 = " "
//
// GET TXA2 SEGMENT 1
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
"1.00" -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_TaxArea2_TXA2 = substr([VA rpt_Description_DSCRP5],0,10)
VA rpt_Description_DSCRP5 = " "
//
// GET EXR2 SEGMENT 2
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
"2.00" -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_TaxExpCod2_EXR2 = substr([VA rpt_Description_DSCRP5],0,2)
VA rpt_Description_DSCRP5 = " "
//
// GET TRAP SEGMENT 3
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
"3.00" -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_PaymentTermAP_TRAP = substr([VA rpt_Description_DSCRP5],0,3)
VA rpt_Description_DSCRP5 = " "
//
// GET PYIN SEGMENT 4
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
"4.00" -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_PaymentInstrument_PYIN = substr([VA rpt_Description_DSCRP5],0,1)
VA rpt_Description_DSCRP5 = " "
//
// GET CRCA SEGMENT 5
//
Parse Text String
VA rpt_Description_DESCR -> BF szInputText
VA rpt_Description_DSCRP5 <- BF szOutputObjectSegment
"5.00" -> BF mnSegmentNumber
"," -> BF cDelimiter
VA rpt_Description_DSCRP5 = rtrim(ltrim([VA rpt_Description_DSCRP5]," ")," ")
VA rpt_CurencyCodeAB_CRCA = substr([VA rpt_Description_DSCRP5],0,3)
VA rpt_Description_DSCRP5 = " "
//
// insert into F0401Z1
//
F0401Z1.Insert
VA rpt_EdiUserId_EDUS -> TK EDI - User ID
VA rpt_EdiBatchNumber_EDBT -> TK EDI - Batch Number
VA rpt_EdiTransactNumber_EDTN -> TK EDI - Transaction Number
VA rpt_EdiLineNumber_EDLN -> TK EDI - Line Number
VA rpt_CurrencyCodeAP_CRRP -> TK Currency Code - Accounts Payable
VA rpt_TaxArea2_TXA2 -> TK Tax Rate/Area 2
VA rpt_TaxExpCod2_EXR2 -> TK Tax Expl Code 2
VA rpt_PaymentTermAP_TRAP -> TK Payment Terms - A/P
VA rpt_PaymentInstrument_PYIN -> TK Payment Instrument
VA rpt_CurencyCodeAB_CRCA -> TK Currency Code - A/B Amounts
If SV File_IO_Status is equal to CO ERROR
//
// write into F0401Z1
//
End If
//
End While
 
I see your problem...but my code works fine in a similar requirement....Please see the sample code, I hope it should help you...

cheers,
Vishnu
 

Attachments

  • 162127-Code.txt
    7.3 KB · Views: 725
If this is the exact code and you haven't missed anything....I didn't find the "Fetch Next Line from Flat File" function call again in the WHILE loop. Did I miss something here???

Cheers,
Vishnu
E900|| TR 8.98.3.2 || SQL SERVER 2008
 
Thank u..sry for late reply

The value for that genericlong(i.e fileptr) is coming randomly.
First time when I executed it(through debugging) the genericlong value came as 12,second time 14,trird time 13 etc...

so what should be the actual value and how to get that
 
When you call the BSFN in the WHILE loop, did it fix your issue. or you are still stuck?

The GENLNG value has least to do with your issue, the fetch should go on till the GENLNG is equal to <zero>.
 
It is important to setup your batch process and the text file encoding with the P93081 application (which only runs from the Fat Client).
 
Back
Top