Question Basic Question For Buffer

Hello Guys,

I was trying to transfer a record of a data that I exported to .txt and put it to the current table using a buffer. I am having some errors about data type, it's like the delimeter "," didn't follow the order of the table I buffered??.. This is the code...


Code:
DEFINE BUFFER xinvhdr FOR inv-hdr-file.
  
INPUT FROM "C:\Documents and Settings\carlo\Desktop\_Carlo\Test\sample2.txt".

REPEAT:
   CREATE xinvhdr.
   IMPORT DELIMITER ",":U xinvhdr.
END.

FOR EACH xinvhdr .
CREATE inv-hdr-file NO-ERROR
    .
    ASSIGN

      inv-hdr-file.beg_bal         =    xinvhdr.beg_bal
      inv-hdr-file.date_forwarded  =    xinvhdr.date_forwarded
      inv-hdr-file.end_bal         =    xinvhdr.end_bal
      inv-hdr-file.fscl_prd        =    xinvhdr.fscl_prd
      inv-hdr-file.fscl_yr         =    xinvhdr.fscl_yr
      inv-hdr-file.in_qty          =    xinvhdr.in_qty
      inv-hdr-file.item_code       =    xinvhdr.item_code
      inv-hdr-file.item_desc       =    xinvhdr.item_desc
      inv-hdr-file.item_specs[1]   =    xinvhdr.item_specs[1]
      inv-hdr-file.item_specs[2]   =    xinvhdr.item_specs[2]
      inv-hdr-file.item_specs[3]   =    xinvhdr.item_specs[3]
      inv-hdr-file.min_level       =    xinvhdr.min_level
      inv-hdr-file.pending_req     =    xinvhdr.pending_req
      inv-hdr-file.qty             =    xinvhdr.qty
      inv-hdr-file.qty_rel         =    xinvhdr.qty_rel
      inv-hdr-file.qty_req         =    xinvhdr.qty_req
      inv-hdr-file.qty_ret         =    xinvhdr.qty_ret
      inv-hdr-file.type            =    xinvhdr.TYPE
      inv-hdr-file.unit_price      =    xinvhdr.unit_price
      inv-hdr-file.uom_code        =    xinvhdr.uom_code       NO-ERROR.


END.
INPUT CLOSE.

But if I tried to define a temp-table with assigned fields, it was created :) thanks and I really appreciate to those who will reply this..
 
I think your understanding of buffers is off. A buffer is not a temp table or a copy of a table, it is essentially an alternate name for the table in question which you can query independently of any other buffers in scope, such as the primary buffer.
 
I can only second Cringer. I think you do not understand what a buffer is.

A buffer neither is a database table nor a temp-table. A buffer is an objectwhich allows you to fetch 1 record of either a database table or a temp-table record into it and access the contents of that record. You can update fields or delete the record and those changes are propogated back to the database table or temp-table record at the end of the buffer or transaction scope - whichever comes first.

Only with a buffer your are able to access records and their fields from either a database table or temp-table. In order to access the records and their fields you fetch the records into the buffer.

You can define almost as many "defined" buffers for a database or temp-table as you like.

What might confuse things is that you can reference database and temp-table fields statically directly with their name. But, in reality, you don't reference the database or temp-table fields, you reference the fields of the default buffer that comes with those which has the same name like the database table or temp-table. This is one thing the ABL does for you and most of the time you don't think about it.

As soon as you work with dynamic buffers it becomes much more obvious.

Heavy Regards, RealHeavyDude.
 
Back
Top