2012 Sep 05 11:31 PM
Hi,
I need to use a ABAP condition in a BW Transformation. I need to ignore data with letters. This letters can exist in any part of sentence. In resume, a need load only numeric data.
I just started learn about ABAP now. How can I write this type of condition? I will include this condition in the same condition existent, that condition read a range of numbers and give names to this, already that the field is the same.
Regards.
Flávia.
2012 Sep 06 1:11 AM
Hi
Your requirement is to differentiate between numbers, and not numbers? Like, does interpunction etc make a difference, are the numbers formatted (contain any dots or comma's) etc. Or are you just trying to ignore things with letters in it. Meaning, something like "1-123$#" does not contain letters...
If it's really just letters, you can try something like:
FIND REGEX '[A-Za-z]' IN (your variable).
IF sy-subrc = 0.
"contains letters
ELSE.
"does not contain letters
ENDIF.
2012 Sep 06 1:11 AM
Hi
Your requirement is to differentiate between numbers, and not numbers? Like, does interpunction etc make a difference, are the numbers formatted (contain any dots or comma's) etc. Or are you just trying to ignore things with letters in it. Meaning, something like "1-123$#" does not contain letters...
If it's really just letters, you can try something like:
FIND REGEX '[A-Za-z]' IN (your variable).
IF sy-subrc = 0.
"contains letters
ELSE.
"does not contain letters
ENDIF.
2012 Sep 06 1:57 PM
Hi Jorg,
The best place to put this code is the Star Routine or in a existent transformation for the same characteristic ?
With this code we separe datas with letters, but I need to separe and save only numeric datas in the DSO. Can you help me with the abap code?
Regards.
Flávia.
2012 Sep 06 6:32 PM
Hi again Jorg,
The code will be that ?
PROGRAM trans_routine.
*---------------------------------------------------------------------*
* CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
* Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
* Available information: Refer to methods of
* interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
PRIVATE SECTION.
TYPE-POOLS: rsd, rstr.
* Rule specific types
TYPES:
BEGIN OF _ty_s_SC_1,
* InfoObject: CA_1666 Controle Contas.
/BIC/CA_1666 TYPE /BIC/OICA_1666,
* InfoObject: 0GL_ACCOUNT Conta do Razão.
GL_ACCOUNT TYPE /BI0/OIGL_ACCOUNT,
* Field: RECORD.
RECORD TYPE RSARECORD,
END OF _ty_s_SC_1.
TYPES:
BEGIN OF _ty_s_TG_1,
* InfoObject: 0GL_ACCOUNT Conta do Razão.
GL_ACCOUNT TYPE /BI0/OIGL_ACCOUNT,
END OF _ty_s_TG_1.
*$*$ begin of global - insert your declaration only below this line *-*
... "insert your code here
*$*$ end of global - insert your declaration only before this line *-*
METHODS
compute_0GL_ACCOUNT
IMPORTING
request type rsrequest
datapackid type rsdatapid
SOURCE_FIELDS type _ty_s_SC_1
EXPORTING
RESULT type _ty_s_TG_1-GL_ACCOUNT
monitor type rstr_ty_t_monitor
RAISING
cx_rsrout_abort
cx_rsrout_skip_record
cx_rsrout_skip_val.
METHODS
invert_0GL_ACCOUNT
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
i_r_selset_outbound TYPE REF TO cl_rsmds_set
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO cl_rsmds_universe
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO cl_rsmds_set
c_exact TYPE rs_bool.
*$*$ begin of 2nd part global - insert your code only below this line *
... "insert your code here
*$*$ end of 2nd part global - insert your code only before this line *
*---------------------------------------------------------------------*
* CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.
METHOD compute_0GL_ACCOUNT.
* IMPORTING
* request type rsrequest
* datapackid type rsdatapid
* SOURCE_FIELDS-/BIC/CA_1666 TYPE /BIC/OICA_1666
* SOURCE_FIELDS-GL_ACCOUNT TYPE /BI0/OIGL_ACCOUNT
* EXPORTING
* RESULT type _ty_s_TG_1-GL_ACCOUNT
DATA:
MONITOR_REC TYPE rsmonitor.
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.
... "to skip a record
* raise exception type CX_RSROUT_SKIP_RECORD.
... "to clear target fields
* raise exception type CX_RSROUT_SKIP_VAL.
FIND REGEX '[A-Za-z]' IN SOURCE_FIELDS-/BIC/CA_1666.
IF sy-subrc = 0.
"contains letters
RESULT = 0.
ELSE.
"does not contain letters
ENDIF.
IF SOURCE_FIELDS-/BIC/CA_1666 = 'GRP1'.
RESULT = 'AJU_FICO_P'.
ENDIF.
IF SOURCE_FIELDS-/BIC/CA_1666 = 'GRP2'.
RESULT = 'AJU_FICO_M'.
ENDIF.
IF SOURCE_FIELDS-/BIC/CA_1666 = 'GRP3'.
RESULT = 'AJU_FICO_S'.
ENDIF.
IF SOURCE_FIELDS-/BIC/CA_1666 = 'GRP4'.
RESULT = 'AJU_FICO_O'.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "compute_0GL_ACCOUNT
*----------------------------------------------------------------------*
* Method invert_0GL_ACCOUNT
*----------------------------------------------------------------------*
*
* This subroutine needs to be implemented only for direct access
* (for better performance) and for the Report/Report Interface
* (drill through).
* The inverse routine should transform a projection and
* a selection for the target to a projection and a selection
* for the source, respectively.
* If the implementation remains empty all fields are filled and
* all values are selected.
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
METHOD invert_0GL_ACCOUNT.
*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*
ENDMETHOD. "invert_0GL_ACCOUNT
2012 Sep 06 6:14 AM
Hi,
The below link might help you.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/frameset.htm
Regards,
Nandha
2012 Sep 10 1:17 PM
I´m trying to write a abap code now, i wrote something like that:
FIND REGEX '[A-Za-z]' IN SOURCE_FIELDS-/BIC/CA_1666.
IF sy-subrc = 0.
"contains letters
RESULT = 0.
ELSE.
"does not contain letters
ENDIF.
I´m thinking about put this code on the start routine in the transformation between the source and DSO.
This abap code is correct? In this case a will take and save only numeric datas in the /BIC/CA_1666 ?
Thanks a lot.
Flávia.
2012 Sep 10 1:42 PM
HIii,
try this ,
DATA text TYPE string VALUE '/BIC/CA_1666'.
FIND REGEX '[A-Za-z]' IN '/BIC/CA_1666'.
IF sy-subrc = 0.
REPLACE ALL OCCURRENCES OF REGEX '\D' IN text WITH ''.
WRITE : text.
* WRITE : 'error'.
ELSE.
"does not contain letters
ENDIF.