SlideShare a Scribd company logo
1 of 3
ABAP FIELD SYMBOL - Techniques for manupulating data using
the FIELD-SYMBOL statement

The most useful thing a field symbol allows you to do is reference any field/variable
on the fly by just putting the name of a field into a variable and assigning a field
symbol to it. Sorry this is proving more difficult to describe than I thought it would
be but one use for this could be if you had a list of field names stored in a table, you
would be able to loop around that table and access the fields stored in it. So for the
following simple example code would contain the value ‘hello’ and would contain the
value ‘LD_FIELD2’
Data: ld_field1 type string.
Data: ld_field2 type string.
FIELD-SYMBOLS: <fs1>, <fs2>.
concatenate ‘LD_FIELD2’ into ld_field1.
Ld_field2 = ‘hello’.
ASSIGN (ld_field1) TO <fs1>.
ASSIGN ld_field1 TO <fs2>.
Below is an example executable ABAP program that uses field symbols to hopefully
should how field symbols work in more detail!
*Code to demonstrate field-symbols
REPORT

zfield_symbols

TYPES: BEGIN OF t_p0121,
pernr TYPE pa0121-pernr,
rfp01 TYPE pa0121-rfp01,
rfp02 TYPE pa0121-rfp02,
rfp03 TYPE pa0121-rfp03,
rfp04 TYPE pa0121-rfp04,
END OF t_p0121.
DATA: it_p0121 TYPE STANDARD TABLE OF t_p0121 INITIAL SIZE 0,
wa_p0121 TYPE t_p0121.
DATA: gd_index TYPE string,

.
gd_rfp0 TYPE string.
FIELD-SYMBOLS: <fs1>, <fs2>.
****************************************************************
*Start-of-selection.
START-OF-SELECTION.
SELECT pernr
rfp01
rfp02
rfp03
rfp04
UP TO 10 ROWS
FROM pa0121
INTO TABLE it_p0121.
****************************************************************
*End-of-selection.
END-OF-SELECTION.
WA_P0121-RFP01 = '1234'.
CONCATENATE 'WA_P0121-RFP01'

gd_index INTO gd_rfp0.

* Now watch how the values change as you loop around the table fields
LOOP AT it_p0121 INTO wa_p0121.
write:/.
write:/ wa_p0121-pernr.
CLEAR: gd_index.
DO.
gd_index = gd_index + 1.
CONCATENATE 'WA_P0121-RFP0'

gd_index INTO gd_rfp0.

* assign with brackets
ASSIGN (gd_rfp0) TO <fs1>.

"assigns the value of field name

contained in variable
* fs1 value would be the value of the field WA_P0121-RFP01..21
* i.e. if index 1 and WA_P0121-RFP01 = 1234 then fs1 would = 1234
* assign without brackets
ASSIGN gd_rfp0 TO <fs2>. " assigns the exact value contained in the
field
* fs1 value would literally be the same as the field WA_P0121-RFP01..21
* i.e. if index 1 then fs2 would = 'WA_P0121-RFP01'
*

index 2 then fs2 would = 'WA_P0121-RFP02' etc...

* you may also notice that once assigned any change made to the field
gd_rfp0
* is instantly reflected in the field symbol (fs2) so technically you
could perform
* the assign command once outside of the loop, but i have left it here to
aid
* readability.
write:/ <fs2>, <fs1>.
IF gd_index GE 21. "exit once last field has been read
EXIT.
ENDIF.
ENDDO.
ENDLOOP

More Related Content

What's hot (19)

Spss syntax
Spss syntaxSpss syntax
Spss syntax
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
11 things about 11gr2
11 things about 11gr211 things about 11gr2
11 things about 11gr2
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
Sql basics
Sql basicsSql basics
Sql basics
 
Technical
TechnicalTechnical
Technical
 
Les09
Les09Les09
Les09
 
Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
 
Les01
Les01Les01
Les01
 
Les11
Les11Les11
Les11
 
Optiva-13449_TestResults
Optiva-13449_TestResultsOptiva-13449_TestResults
Optiva-13449_TestResults
 
Les10
Les10Les10
Les10
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraint
 
Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
 
75864 sql
75864 sql75864 sql
75864 sql
 
V23 function-2
V23 function-2V23 function-2
V23 function-2
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 

Similar to ABAP FIELD SYMBOLS - Manipulate data using FIELD-SYMBOL

Report zcomprasreporte abap
Report zcomprasreporte abapReport zcomprasreporte abap
Report zcomprasreporte abapDavid Roque
 
Abap performance tunning tips
Abap performance tunning tipsAbap performance tunning tips
Abap performance tunning tipsJay Dalwadi
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationRai University
 
Mca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageMca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageRai University
 
ABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLEABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLEvr1sap
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionaryvkyecc1
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfSreeramBaddila
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniquesJugul Crasta
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releasesGeorgi Sotirov
 
100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPSNirmal Pati
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhuteAniket Bhute
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAPsapdocs. info
 

Similar to ABAP FIELD SYMBOLS - Manipulate data using FIELD-SYMBOL (20)

Report zcomprasreporte abap
Report zcomprasreporte abapReport zcomprasreporte abap
Report zcomprasreporte abap
 
Mona cheatsheet
Mona cheatsheetMona cheatsheet
Mona cheatsheet
 
Abap performance tunning tips
Abap performance tunning tipsAbap performance tunning tips
Abap performance tunning tips
 
System programs in C language.
System programs in C language.System programs in C language.
System programs in C language.
 
Assembler Numerical in system programming
Assembler Numerical in system programmingAssembler Numerical in system programming
Assembler Numerical in system programming
 
Bsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalizationBsc cs ii-dbms-u-iv-normalization
Bsc cs ii-dbms-u-iv-normalization
 
Mca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query languageMca ii-dbms-u-iv-structured query language
Mca ii-dbms-u-iv-structured query language
 
ABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLEABAP EVENTS EXAMPLE
ABAP EVENTS EXAMPLE
 
Abap 7.40
Abap 7.40Abap 7.40
Abap 7.40
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
 
Sql
SqlSql
Sql
 
Report zalv
Report  zalvReport  zalv
Report zalv
 
modularization-160202092213 (1).pdf
modularization-160202092213 (1).pdfmodularization-160202092213 (1).pdf
modularization-160202092213 (1).pdf
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Basic programming
Basic programmingBasic programming
Basic programming
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releases
 
100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhute
 
Function and types
Function  and typesFunction  and types
Function and types
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 

Recently uploaded

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 

ABAP FIELD SYMBOLS - Manipulate data using FIELD-SYMBOL

  • 1. ABAP FIELD SYMBOL - Techniques for manupulating data using the FIELD-SYMBOL statement The most useful thing a field symbol allows you to do is reference any field/variable on the fly by just putting the name of a field into a variable and assigning a field symbol to it. Sorry this is proving more difficult to describe than I thought it would be but one use for this could be if you had a list of field names stored in a table, you would be able to loop around that table and access the fields stored in it. So for the following simple example code would contain the value ‘hello’ and would contain the value ‘LD_FIELD2’ Data: ld_field1 type string. Data: ld_field2 type string. FIELD-SYMBOLS: <fs1>, <fs2>. concatenate ‘LD_FIELD2’ into ld_field1. Ld_field2 = ‘hello’. ASSIGN (ld_field1) TO <fs1>. ASSIGN ld_field1 TO <fs2>. Below is an example executable ABAP program that uses field symbols to hopefully should how field symbols work in more detail! *Code to demonstrate field-symbols REPORT zfield_symbols TYPES: BEGIN OF t_p0121, pernr TYPE pa0121-pernr, rfp01 TYPE pa0121-rfp01, rfp02 TYPE pa0121-rfp02, rfp03 TYPE pa0121-rfp03, rfp04 TYPE pa0121-rfp04, END OF t_p0121. DATA: it_p0121 TYPE STANDARD TABLE OF t_p0121 INITIAL SIZE 0, wa_p0121 TYPE t_p0121. DATA: gd_index TYPE string, .
  • 2. gd_rfp0 TYPE string. FIELD-SYMBOLS: <fs1>, <fs2>. **************************************************************** *Start-of-selection. START-OF-SELECTION. SELECT pernr rfp01 rfp02 rfp03 rfp04 UP TO 10 ROWS FROM pa0121 INTO TABLE it_p0121. **************************************************************** *End-of-selection. END-OF-SELECTION. WA_P0121-RFP01 = '1234'. CONCATENATE 'WA_P0121-RFP01' gd_index INTO gd_rfp0. * Now watch how the values change as you loop around the table fields LOOP AT it_p0121 INTO wa_p0121. write:/. write:/ wa_p0121-pernr. CLEAR: gd_index. DO. gd_index = gd_index + 1. CONCATENATE 'WA_P0121-RFP0' gd_index INTO gd_rfp0. * assign with brackets ASSIGN (gd_rfp0) TO <fs1>. "assigns the value of field name contained in variable * fs1 value would be the value of the field WA_P0121-RFP01..21
  • 3. * i.e. if index 1 and WA_P0121-RFP01 = 1234 then fs1 would = 1234 * assign without brackets ASSIGN gd_rfp0 TO <fs2>. " assigns the exact value contained in the field * fs1 value would literally be the same as the field WA_P0121-RFP01..21 * i.e. if index 1 then fs2 would = 'WA_P0121-RFP01' * index 2 then fs2 would = 'WA_P0121-RFP02' etc... * you may also notice that once assigned any change made to the field gd_rfp0 * is instantly reflected in the field symbol (fs2) so technically you could perform * the assign command once outside of the loop, but i have left it here to aid * readability. write:/ <fs2>, <fs1>. IF gd_index GE 21. "exit once last field has been read EXIT. ENDIF. ENDDO. ENDLOOP