Ir al contenido principal

Manejo y asignación de Field symbols

Un ejemplo simple, de cómo manejar tablas para acceso dinámico, por medio de field symbols.

REPORT demo_field_symbols_stat_assign .

DATABEGIN OF line,
         col1 TYPE VALUE 11,
         col2 TYPE VALUE 22,
         col3 TYPE VALUE 33,
      END OF line.

DATA comp(5TYPE VALUE 'COL3'.

FIELD-SYMBOLS<f1> TYPE ANY<f2> TYPE ANY<f3> TYPE ANY.

ASSIGN line TO <f1>.
ASSIGN comp TO <f2>.

  DO TIMES.
  ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f3>.
  WRITE <f3>.
  ENDDO.

ASSIGN COMPONENT <f2> OF STRUCTURE <f1> TO <f3>.
WRITE / <f3>.

*Listado de salida:
*
*11         22         33
*
*33
*
* El símbolo del campo <f1> apunta a la línea de la estructura, <f2> apunta * al campo comp.
* En el bucle de OD, los componentes de la línea se especifican por sus números y* se asignan uno por uno a <f3>.
* Después del bucle, los componentes col3 se especifican por sus nombres 
y se asignan a <f3>.
* Tenga en cuenta que ASSIGN COMPONENT es el único método posible para 
* direccionar los componentes de <f1>.
* Las expresiones como <f1> -col1 son sintácticamente incorrectas.

Fuente: https://help.sap.com/doc/saphelp_nw70/7.0.31/en-US/fc/eb3923358411d1829f0000e829fbfe/content.htm?no_cache=true

Comentarios

Entradas más populares de este blog

How to add custom field in Additional B Tab for SAP Sales Order In this article we want to explain step by step how to add custom field in SAP Sales Order transaction VA01/VA02/VA03. This time Mr ABAPGurus will give the tutorial of enhancement to add custom field in SAP Sales order. In this sample we will add new custom field for comments and customer satisfaction, this data will save into separate table from SAP Standard table ( VBAK / VBAP ). SAP provided us with ADDITIONAL TAB in the sales order transaction ( VA01/VA02/VA03 ) which allow customer to add custom fields.  T he different between ADDITIONAL A and ADDITIONAL B is the ADDITIONAL A for field which already predefine in Sales Order Header ( VBAK ) fields and ADDITIONAL B is for field that freely define. This sample we will use ADDITIONAL B because we will store data from customer satisfaction into Z database table. 1. Create one Z table using SE11 SAP Transaction code. 2.Using SE38 Transactio...

A to Z of OLE Excel in ABAP 7.4

  SAP users, both business and end users always need to download the output of a report to spreadsheet and do their analytics.   The standard excel output from a report is very simple process but it is old fashioned and the spreadsheet looks quite boring.  There is no default formatting and the users have to do all the hard work of changing the fonts, coloring the texts, marking the borders etc. Updated 16th Aug 2019  –  If you are working in non-ABAP 7.4 (below), there is complete reference program for you too. Go to the end of this article.  Thank you  Legxis  ( LeonievonK ) for the share. I acknowledge, whatever I mentioned above can be achieved in many ways programmatically. We can do it in the old traditional ABAP way but  providing multiple tabs in the spreadsheet and formatting is quite tricky with non  OLE  method. OLE = Object Linking and Embedding The high level agenda of this article is to be the  G.O.A.T.  (ple...

BADI ME_PROCESS_PO_CUST para pedidos de compra

  En este post vamos a ver una de las BADI´s mas utilizadas dentro de SAP. No es otro que la BADI  ME_PROCESS_PO_CUST  que se utiliza para incluir funcionalidad dentro de los pedidos de compra ( ME21N ,  ME22N ,  ME23N ) a través de los diferentes métodos que pone a nuestra disposición. Para los que no tengáis claro que es una BADI os dejo el siguiente link del blog donde ya hablamos sobre ellas: http://sapuniverse.blogspot.com.es/2014/05/badis-en-sap.html El primer paso si queremos utilizar esta BADI sería implementarla y activarla. Para ello debemos utilizar la transacción  SE19.  Aquí introduciremos el nombre de la BADI y pulsaremos sobre el botón " IMPLEMENTAR " como se ve en la siguiente imagen: Tras esto el sistema nos pedirá que asignemos un nombre a nuestra implementación. Tras aceptar el sistema nos mostrará la implementación que se va a crear. Podremos ver todos los métodos que están disponibles y en los que vamos a poder introducir código. A...