Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help to change this code to daynmic

Former Member
0 Kudos

hi,

i have this code and insted to write it many time there is a better way to write it?

the change is : name & value.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = '&vendorname&'

value = is_invoice_table-vendor_name

value_length = 0

replace_symbols = ' '.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = '&invoicedate&' "

value = is_invoice_table-invoice_date

value_length = 0

replace_symbols = ' '.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = '&invoicenumber&'

value = is_invoice_table-invoice_number

value_length = 0

replace_symbols = ' '.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

You can try this

perform text_value using &vendorname&

is_invoice_table-vendor_name.

perform text_value using '&invoicedate&'

is_invoice_table-invoice_date.

perform text_value using &invoicenumber&

is_invoice_table-invoice_number.

form text_value using name value.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = name

value = value

value_length = 0

replace_symbols = ' '.

endform.

Regards

Madhan

10 REPLIES 10

Former Member
0 Kudos

Hi

You can try this

perform text_value using &vendorname&

is_invoice_table-vendor_name.

perform text_value using '&invoicedate&'

is_invoice_table-invoice_date.

perform text_value using &invoicenumber&

is_invoice_table-invoice_number.

form text_value using name value.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = name

value = value

value_length = 0

replace_symbols = ' '.

endform.

Regards

Madhan

0 Kudos

if data is available in Internal table .

just loop the table and pass the values to this perfom statment inside the loop

perform text_value using &it_var1& &it_var2&

endloop.

thanks

Regards

0 Kudos

Hi Madhan Doraikannan,

thanks ,

i try it but i have problem when i create the perform ( perform text_setvalue using '&vendorname&' value .) i get :

FORM TEXT_SETVALUE USING VALUE(P_0072) P_VALUE.

what i have to put thier (in bold)?

Regards

0 Kudos

Hi

perform text_value using &vendorname&

is_invoice_table-vendor_name.

When you double click on text_value.

It will create

FORM TEXT_VALUE USING P_xxx p_xxxx.

ENDFORM.

You can call the function module between the FORM and ENDFORM.

Regards

Madhan

0 Kudos

Hi Madhan,

Thanks ,

but i do :

perform text_setvalue using '&vendorname&'  value .

and i get :

*&---------------------------------------------------------------------*
*&      Form  TEXT_SETVALUE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0072   text
*      -->P_VALUE  text
*----------------------------------------------------------------------*
FORM TEXT_SETVALUE  USING    VALUE(P_0072)
                             P_VALUE.

ENDFORM.                    " TEXT_SETVALUE

what i have to put instead (P_0072)?

Regards

0 Kudos

Hi

You can remove VALUE(P_0072) and change to P_NAME manually.

and with in

FORM TEXT_VALUE.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = p_name

value = p_value

value_length = 0

replace_symbols = ' '.

ENDFORM.

But after every perform, you need to move the value P_NAME and P_VALUE to required variables

Regards

Madhan

former_member182426
Active Contributor
0 Kudos

hi,

u can use loop at table statement like this....

for this u keep all the names in one temp itab.

LOOP AT itab.

clear: temp1, temp2.

move itab-name to temp1.

move is_invoice_table-vendor_name to temp2.

CALL FUNCTION 'TEXT_SETVALUE'

EXPORTING

name = temp1

value = temp2

value_length = 0

replace_symbols = ' '.

ENDLOOP.

You can use field symbols also.

Regards,

shankar.

matt
Active Contributor
0 Kudos

This will work for the values- but for the name, you'll need perhaps to include the name value in some kind of mapping internal table.

FIELD-SYMBOLS: <l_fld> TYPE ANY.

l_count = 0.
DO.
  ASSIGN COMPONENT l_count OF STRUCTURE is_invoice_table TO <l_fld>.
  IF <l_fld> IS NOT ASSIGNED.
    EXIT.
  ENDIF.

  CLEAR ls_map_table.
  READ TABLE t_map_table WITH TABLE KEY i_fld_count = l_count INTO ls_map_table.
  
  CALL FUNCTION 'TEXT_SETVALUE'
  EXPORTING
    name = ls_map_table-description 
    value = <fld>
    value_length = 0
    replace_symbols = ' '.
  ADD 1 TO l_count.
ENDDO.

matt

Former Member
0 Kudos

Hi matt,

maybe u can explain me about:

CLEAR ls_map_table.

READ TABLE t_map_table WITH TABLE KEY i_fld_count = l_count INTO ls_map_table.

Regards

matt
Active Contributor
0 Kudos

>

> Hi matt,

>

> maybe u can explain me about:

>

> CLEAR ls_map_table.

> READ TABLE t_map_table WITH TABLE KEY i_fld_count = l_count INTO ls_map_table.

>

> Regards

Your original question was how to make the code dynamic. However, the answers you've accepted are not dynamic programming. I assumed that you had a bunch of fields in a structure, and wanted to call the function module for each field, no matter what the fields were. Not just simplify the calling of the function module by encapsulating in a form..

The idea t_map_table was to provide a link between the field position and the name of the field. You could also use RTTS to get this.