ABAP/4 Tools Newsletter
mail at abaptools.com
mail at abaptools.com
Wed Aug 21 02:13:41 CEST 2002
*******************************************************
ABAP/4 Tools Newsletter #1, August 19, 2002
*******************************************************
NEWS: Our new domain http://www.abaptools.com is now fully active with links to hundreds of ABAP/4 program samples. We are the largest single source of ABAP/4 code on the web. We also carry discounted software, books and utilities for the ABAP programmer available via secured purchase.
AUGUST SPECIAL: SAVE $20 when you purchase the Data Dictionary and TableView Light Combo. The DataSuite Data Dictionary is the Windows stand-alone utility that allows viewing and analysis of R/3 data structures. TableView Light is a data migration and ABAP generation utility that extracts data to Windows destinations and builds ABAP code.
Take advantage of this special offer and receive both of these popular utilities at significant savings. For more information, visit http://www.abaptools.com today.
AUGUST BOOK SPECIAL: SAP R/3 Data Integration Techniques Using ABAP/4 and Visual Basic. Only 39.95 US. A savings of 10.00 off the Amazon price.
FEATURED ABAP/4: The example ABAP below demonstrates how to manually parse individual fields from an ASCII delimited text file. A record is simulated using the DATA statements, and the fields are extracted and written to the display.
-----------------------------------------------------------------------------------------------------
REPORT YDLMTEXT .
* Demonstration of the use of field symbols to parse a delimited ascii *
* text file. The max length of the input record must be known so that *
* a buffer can be setup large enough to handle the record (line). *
DATA: C25(25) TYPE C, " Work Field (will hold field value)
COUNTER TYPE I VALUE 1. " Number of fields in input string
* Buffer. This represents one 'line' as read from a text file *
DATA: BEGIN OF BUFF,
B1(69) TYPE C VALUE
'"Well","she","was","just","seventeen","you","know","what","I","mean",',
B2(64) TYPE C VALUE
'"and","the","way","she","looked","was","way","beyond","compare",',
B3(60) TYPE C VALUE
'"So","how","could","I","dance","with","another","whooooooo",',
B4(41) TYPE C VALUE
'"when","I","saw","her","standing","there"'.
DATA END OF BUFF.
START-OF-SELECTION.
WHILE COUNTER LT 34. " Execute for each field to parse
PERFORM NEXT_FIELD USING BUFF C25. " #1
WRITE:/1 C25.
COUNTER = COUNTER + 1 .
ENDWHILE.
** Routine to get the next field and adjust the input line **
FORM NEXT_FIELD CHANGING TL BF.
DATA: CMA TYPE I, " Location of Comma
BDX TYPE I, " Workin Index
LBT(1) TYPE C. " Leftmost byte
FIELD-SYMBOLS: <FLD>, <FL2>.
CLEAR BF.
CHECK NOT TL IS INITIAL.
LBT = TL.
IF LBT EQ '"'. " COMMA WITHIN DBL QUOTES
ASSIGN TL+1 TO <FLD>.
TL = <FLD>. " ELIMINATE FIRST DQ
WHILE <FL2> NE '"' AND ( NOT TL IS INITIAL ) .
ASSIGN TL+0(1) TO <FLD>.
ASSIGN TL+0(1) TO <FL2>.
IF <FLD> NE ',' AND <FLD> NE '"'.
CONCATENATE BF <FLD> INTO BF.
ENDIF.
ASSIGN TL+1 TO <FLD>.
TL = <FLD>.
ENDWHILE.
ASSIGN TL+2(232) TO <FLD>. " MUST ALWAYS BE RECLEN - 2 .
TL = <FLD>.
EXIT.
ENDIF.
** No double-quotes, just parse through comma ***
IF TL CA ','.
CMA = SY-FDPOS + 1.
IF CMA GT 1.
BDX = CMA - 1 .
ASSIGN TL+0(BDX) TO <FLD>.
BF = <FLD> .
ELSE.
CLEAR BF.
ENDIF.
BDX = CMA.
ASSIGN TL+CMA TO <FLD>.
TL = <FLD>.
ELSE.
BF = TL .
CLEAR TL.
ENDIF.
ENDFORM.
-----------------------------------------------------------------------------------------------------------------
That's all for August. As always, we ask users to submit favorite ABAP routines to http://www.abaptools.com
***********************************************************************************
This newsletter is a monthly service of abaptools.com. To be removed
from our mailing list, simply reply to this newsletter with 'remove' in
the subject line.
More information about the Elektro
mailing list