Code: Alles auswählen.
FORM convert_amount_to_char17 USING structdata TYPE any
struct_of_list TYPE any
act_curr TYPE any.
DATA: descr_ref TYPE REF TO cl_abap_structdescr,
lv_buffer TYPE char17,
ls_usdefaults TYPE usdefaults,
lv_c TYPE p VALUE 0,
lv_cellname type string.
FIELD-SYMBOLS: <comp_wa> TYPE abap_compdescr,
<fs_my> type any.
descr_ref ?= cl_abap_typedescr=>describe_by_data( struct_of_list ).
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
lv_c = lv_c + 1.
IF <comp_wa>-type_kind EQ 'P' AND <comp_wa>-decimals EQ 2.
ASSIGN COMPONENT lv_c OF STRUCTURE struct_of_list TO <fs_my>.
lv_cellname = <comp_wa>-name.
* Write amount to buffer
WRITE <fs_my> TO lv_buffer CURRENCY act_curr.
CALL FUNCTION 'SUSR_USER_DEFAULTS_GET'
EXPORTING
user_name = sy-uname
IMPORTING
user_defaults = ls_usdefaults
EXCEPTIONS
user_name_not_exist = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF ls_usdefaults-dcpfm <> space.
REPLACE '.' WITH ':' INTO lv_buffer.
REPLACE ',' WITH '.' INTO lv_buffer.
REPLACE ':' WITH ',' INTO lv_buffer.
ENDIF.
* set the negativ sign in the front of the Value.
IF <fs_my> < 0.
SHIFT lv_buffer RIGHT DELETING TRAILING '-'.
CONDENSE lv_buffer NO-GAPS.
CONCATENATE '-' lv_buffer INTO lv_buffer.
ELSE.
CONDENSE lv_buffer NO-GAPS.
ENDIF.
"Hier müßte ich denn Strukturpfad angeben. Der Feldname liegt in "<comp_wa>-name
"??? ->structdata-(Inhalt von <comp_wa>-name verwenden)<-??? = lv_buffer.
ENDIF.
ENDLOOP.
ENDFORM.
Code: Alles auswählen.
var_name = import_string.
"Hier sollte er aber den Inhalt von var_name als Name nehmen. Wie würde das funktionieren?
types: begin of ls_s,
var_name(17) type c,
end of ls_s.
data:
lv_buffer type ls_s.
"oder.........................
data: var_name(17) type c.
Code: Alles auswählen.
REPORT.
DATA: dref TYPE REF TO data.
FIELD-SYMBOLS: <tab> TYPE table.
PARAMETERS: tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'.
START-OF-SELECTION.
CREATE DATA dref TYPE STANDARD TABLE OF (tabname).
CHECK sy-subrc = 0.
ASSIGN dref->* TO <tab>.
SELECT * UP TO 100 ROWS FROM (tabname) INTO CORRESPONDING FIELDS OF TABLE <tab>.
BREAK-POINT.
Jetzt noch eine Frage kann man hier auch dynamisch eine where Bedingung zusatzlich noch rein Pflanzen und wenn ja wie ?black_adept hat geschrieben:Code: Alles auswählen.
REPORT. DATA: dref TYPE REF TO data. FIELD-SYMBOLS: <tab> TYPE table. PARAMETERS: tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'. START-OF-SELECTION. CREATE DATA dref TYPE STANDARD TABLE OF (tabname). CHECK sy-subrc = 0. ASSIGN dref->* TO <tab>. SELECT * UP TO 100 ROWS FROM (tabname) INTO CORRESPONDING FIELDS OF TABLE <tab>. BREAK-POINT.
Code: Alles auswählen.
REPORT.
DATA: dref TYPE REF TO data.
FIELD-SYMBOLS: <tab> TYPE table.
PARAMETERS: tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'.
parameters: p_where type string default 'LVORM = ''X'' OR MATNR LIKE ''%V%'' '.
START-OF-SELECTION.
CREATE DATA dref TYPE STANDARD TABLE OF (tabname).
CHECK sy-subrc = 0.
ASSIGN dref->* TO <tab>.
SELECT * UP TO 100 ROWS
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE <tab>
where (p_where).
BREAK-POINT.