‎2009 Jun 23 5:36 PM
Hi Experts,
Im having some doubs in order to use assign in a dynamical perform. This is the cenario:
I have 3 tables of the same structure and in a routine they all go to the same perform, and will update the same internal table. I want that the perform be a little dynamic.
Th problem it's that for each internal table, the field to be update it's diferent, and i want to know if it's possible to do what i want using the assign statement. I've allready tried, and the code example goes with my test , but it's not working because instead of update the table field that i want move the value to the field symbol..
Here goes an example of the code:
....
**Docs 41
CLEAR: str_valor, str_num.
str_valor = 'TAB_LISTA-VALOR_41'.
str_num = 'TAB_LISTA-NUM_DOCS_41'.
PERFORM get_values TABLES tab_docs USING str_valor
str_num.
*Docs 61
CLEAR: str_valor, str_num.
str_valor = 'TAB_LISTA-VALOR_61'.
str_num = 'TAB_LISTA-NUM_DOCS_61'.
PERFORM get_values TABLES tab_61 USING str_valor
str_num.
.....
.....
....
FORM get_values TABLES p_tab STRUCTURE tab_docs
USING p_valor
p_num_docs.
DATA lv_bankl TYPE t012-bankl.
DATA lv_hkont TYPE t012k-hkont.
DATA lv_banks TYPE banks.
FIELD-SYMBOLS: <valor> TYPE ANY,
<num_docs> TYPE ANY.
ASSIGN: p_valor TO <valor>,
p_num_docs TO <num_docs>.
LOOP AT p_tab.
CLEAR: lv_bankl, lv_hkont, lv_banks.
MOVE: p_tab-hkont TO lv_hkont,
0 TO lv_hkont+9(1).
*Determinação de Banco - Descritivo
SELECT SINGLE f~bankl f~banks INTO (lv_bankl, lv_banks)
FROM t012 AS f INNER JOIN t012k AS g
ON f~bukrs = g~bukrs
AND f~hbkid = g~hbkid
WHERE g~hkont = lv_hkont
AND g~bukrs = pa_emp.
SELECT SINGLE banka FROM bnka INTO tab_lista-banco
WHERE bankl = lv_bankl
AND banks = lv_banks.
**Calculos para os documentos 41
MOVE: p_tab-hkont TO tab_lista-conta.
WRITE p_tab-dmbtr TO <valor>. "This is where the field to be updated differs
AT NEW belnr.
MOVE 1 TO <num_docs>. "This is where the field to be updated differs
ENDAT.
COLLECT tab_lista.
ENDLOOP.
ENDFORM.
Can anyone help me on this subject??
Thanks in Advance,
Best Regards,
João Martins
‎2009 Jun 23 5:49 PM
Hi,
Here I see some problem on your coding:
Your original coding is:
ASSIGN: p_valor TO <valor>,
p_num_docs TO <num_docs>.The coding should be:
ASSIGN: (p_valor) TO <valor>,
(p_num_docs) TO <num_docs>.Rgds,
Ramani N
‎2009 Jun 23 5:49 PM
Hi,
Here I see some problem on your coding:
Your original coding is:
ASSIGN: p_valor TO <valor>,
p_num_docs TO <num_docs>.The coding should be:
ASSIGN: (p_valor) TO <valor>,
(p_num_docs) TO <num_docs>.Rgds,
Ramani N
‎2009 Jun 23 5:53 PM
In your Subroutine try like this:
ASSIGN: (p_valor) TO <valor>,
(p_num_docs) TO <num_docs>.
I assume that TAB_LISTA is the global table in your program.
Regards,
Naimesh Patel
‎2009 Jun 23 7:29 PM
Hi,
Based on what conditions the updatation of the fields differ? If you want to update the table using field-symbols then better while creating the field-symbols refer them to one of the internal table structures as all the internal tables have same structure. It will be easy to refer to the fields using <fs> else you can not do <fs>-field when the <fs> is being referenced to TYPE ANY. Hope this is clear.
Let me know on what conditions you are going to modify the internal table, please.
Thanks & Regards,
Anand Patil