terça-feira, 26 de maio de 2015

Copy Internal Table to another Internal Table

Code Snippet of Various different options to copy entries from Internal table to another internal table
All of these approaches would copy the entries from ITAB to another ITAB when work as expected when:
  • Both Source and Target has Same structures
  • Target has fewer fields with same types. Rest of the fields would be discarded.
For this code snippet, we would be copying entries to reduced target internal table.

Using LOOP to copy itab to another itab

 
TYPES:
  BEGIN OF ty_vbak,
    vbeln TYPE vbak-vbeln,
    auart TYPE vbak-auart,
    vkorg TYPE vbak-vkorg,
  END   OF ty_vbak.
DATA: t_vbak  TYPE STANDARD TABLE OF ty_vbak.
DATA: ls_vbak LIKE LINE OF t_vbak.
DATA: t_vbeln TYPE STANDARD TABLE OF vbak-vbeln.
DATA: lv_lines TYPE i.
 
* Some test data
SELECT vbeln auart vkorg
  FROM vbak
  INTO TABLE t_vbak
  UP TO 500 ROWS.
 
CLEAR t_vbeln.
LOOP AT t_vbak INTO ls_vbak.
  APPEND ls_vbak-vbeln TO t_vbeln.
ENDLOOP.
 
* Display number of entries in target table
lv_lines = LINES( t_vbeln ).
WRITE lv_lines.
 

Using MOVE to copy

 
CLEAR t_vbeln.
MOVE t_vbak TO t_vbeln.
 
* Display number of entries in target table
lv_lines = LINES( t_vbeln ).
WRITE lv_lines.
 

Using APPEND LINES OF to copy

 
CLEAR t_vbeln.
APPEND LINES OF t_vbak TO t_vbeln.
 
* Display number of entries in target table
lv_lines = LINES( t_vbeln ).
WRITE lv_lines.
 

Using direct copy

 
CLEAR t_vbeln.
t_vbeln = t_vbak.
 
* Display number of entries in target table
lv_lines = LINES( t_vbeln ).
WRITE lv_lines.

terça-feira, 24 de fevereiro de 2015

Codificação de Caractéres do inglês "Character encodings"

In computing, a character encoding is used to represent a repertoire of characters by some kind of an encoding system.[1] Depending on the abstraction level and context, corresponding code points and the resulting code space may be regarded as bit patternsoctets, natural numbers, electrical pulses, etc. A character encoding is used incomputationdata storage, and transmission of textual data. Terms such as character setcharacter mapcodeset or code page are sometimes used as near synonyms; however, these terms have related but distinct meanings described in the article.

Referência: http://en.wikipedia.org/wiki/Code_page