cancel
Showing results for 
Search instead for 
Did you mean: 

How to load values from AUGDT to an attribute conditionally

former_member194898
Active Contributor
0 Kudos

Hi,

There’s need to load values from AUGDT to FACDOCNO__ZCLEAR_DT.

(ZCLEAR_DT is a copy of 0clear_date, FACDOCNO is a characteristic loaded with document numbers (BELNR), ZCLEAR_DT is an attribute of FACDOCNO).

Is there a way to use any formula for it assuming that:

- loading should function only if in a given record there is a value “X” against SAKNR

- an empty string mustn’t overwrite value that has already has been loaded).

Like this:

BELNR     SAKNR     AUGDT

     1               Y            aaa           should not be loaded

     1               X            bbb           should be loaded

     1               X            empty       should not be loaded

     1               X            ccc           should be loaded

Now we have cc value in FACDOCNO_ZCLEAR_DT

My idea is:

IF( NOT IS_INITIAL( AUGDT ) AND SAKNR = 'X' ), AUGDT, SKIP_RECORD( ) )  

But I’m not sure if IS_INITIAL should be used here. Does this check if loaded value is not empty ???

And I’m not sure if SKIP_RECORD will work OK. What exactly in this case that "skip" mean ?? I'm afraid of skipping record in facdocno after encountering the first empty value in the source table.

There are some post's on SCN on that topic but I found nothing to help me so far.

Regards, Leszek

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186399
Active Contributor
0 Kudos

Hello Leszek,

Here is my understanding.

You want to have AUGDT from a datasource (suppose 0FI_AR_3) loaded as an attribute of accounting document based on the value of SAKNR.

In that case you can write a start routine which will load only the data that you require.

for eg, delete source_package where AUGDT IS INITIAL AND SAKNR NE 'X'.

Regards

Gajesh

former_member194898
Active Contributor
0 Kudos

Hi,

My problem is I don't know how to write ABAP code to achieve this. I'ts much easier for me to use a formula.

Instead of formula:

IF( KTOPL = 'PKP' AND ( SAKNR = '0020300010' OR SAKNR = '0020300020' OR SAKNR = '0020300030' OR SAKNR = '0020300040' ), AUGDT, SKIP_RECORD( ) )

(the actuall need is in fact a bit more complicated than I wrote before - I use four different value for saknr and a value for KTOPL )

The code generated after choosing "routine" is:

PROGRAM trans_routine.
CLASS lcl_transform DEFINITION.
  PUBLIC SECTION.
    DATA:
      p_check_master_data_exist
            TYPE RSODSOCHECKONLY READ-ONLY,

      p_r_request
            TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

  PRIVATE SECTION.

    TYPE-POOLS: rsd, rstr.
    TYPES:
      BEGIN OF _ty_s_SC_1,
        AUGDT           TYPE D,
        SAKNR           TYPE C LENGTH 10,
        KTOPL           TYPE C LENGTH 4,
        RECORD           TYPE RSARECORD,
      END   OF _ty_s_SC_1.
    TYPES:
      BEGIN OF _ty_s_TG_1,
        /BIC/ZCLEAR_DT           TYPE /BIC/OIZCLEAR_DT,
      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_ZCLEAR_DT
        IMPORTING
          request                  type rsrequest
          datapackid               type rsdatapid
          SOURCE_FIELDS              type _ty_s_SC_1
        EXPORTING
          RESULT                   type _ty_s_TG_1-/BIC/ZCLEAR_DT
          monitor                  type rstr_ty_t_monitor
        RAISING
          cx_rsrout_abort
          cx_rsrout_skip_record
          cx_rsrout_skip_val.
    METHODS
      invert_ZCLEAR_DT
        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.
ENDCLASS.                    "routine DEFINITION

*$*$ 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 lcl_transform IMPLEMENTATION.

  METHOD compute_ZCLEAR_DT.

    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.

     RESULT = .

*$*$ end of routine - insert your code only before this line         *-*
  ENDMETHOD.                    "compute_ZCLEAR_DT

  METHOD invert_ZCLEAR_DT.

*$*$ 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_ZCLEAR_DT
ENDCLASS.                    "routine IMPLEMENTATION

I'm not sure what to do with it.

Regards, Leszek