Tuesday, February 16, 2016

Delta Management

Types of Delta

There are different types of delta available

ABR - Complete Delta with Deletion Flag Via Delta Queue
After Before Reverse - Here for every change, there is a Before and After image generated and deletions are captured in Reverse Image.
These can be loaded directly to a cube or DSO.
In cube it is only summation and here, for every change we get a -ve and +ve value.
An after image shows the status after the change, a before image shows the status before the change with a negative sign and the reverse image also shows the negative sign next to the record while indicating it for deletion

For say a quantity is 10 initially and loaded to cube, next time if it changes to 8, we get two records.
Record Mode | 'X' | Before image | -10
Record Mode | '  '  | After image | 8


AIE - After Images Via Extractor
Only the after images flow to BW. For the same example, when the change occurs only one record flows into BW
Value 8.
It cannot be loaded to cube directly as in cube there is only Summation and the value becomes 10+8 = 18.
These extractors need to have a DSO with 'overwrite' feature and 10 gets replaced with 8. There records can further be loaded to cube where dso generates before and after images for cube to handle.

RecordMode | ROCANCEL

ROCANCEL
This is a default field in all datasoures which work on delta - ABR.
Whenever a change occurs, system generates 2 records
ROCANCEL = 'X' -- Old record
ROCANCEL = ' '   -- New record
ROCANCEL = 'R  -- Deleted record

Mapping of ROCANCEL and 0RECORDMODE
For example, your PSA has one PO with 2 line items 10 and 20. Line 10 comes with a change , so there is 'X' record with Old values and ' ' record with  with New values. Line 20 is deleted in source, so Line 20 comes with 'R' image.

ROCANCEL is mapped to 0RECORDMODE in the DSO
This is mostly the way the mapping is done.
ROCANCEL is mapped to RECORDMODE in Technical Rule Group.
Once the DTP is run, you get the PO with 2 Lines - Line 10 with after image value and Line 20 with R to the NEW Data table.
When activated, only Line 10 is added to the DSO. Line 20 is deleted.

0RECORDMODE is blank constant.
Both PO Lines items flow to New Data and then up on activation both lines are available in DSO. you would not know that the entry is deleted in the source. 
In this scenario, what you are making RECORDMODE as BLANK , so when data is being loaded to the DSO, it does not know what kind of record you are loading to the DSO and treats all records as new records and just overwrites them.

0RECORDMODE = 'R'
This is used when you want to delete entries from DSO. If you want to do delete some data using transformation, make 0RECORDMODE = 'R'. So what ever record passes through the transformation is considered as Reverse Image and when loaded to the DSO and activated will get deleted.



Extra Notes : ROCANCEL | RECORDMODE


Pulling Delta to BW
Steps : 
  • Run the V3 jobs in the source ( Either manually / or the standard V3 jobs ). This is only for Queued Delta.
  • Check LBWQ entries. Once the V3 jobs run, all the data move from LBWQ to RSA7.
  • Run the infopackage to pull data from RSA7 to BW.
RSA7
As you know delta entries to BW are pulled from RSA7 queue. But, sometimes, even when changes are done in PE system, when you pull delta, the new changes donot get pulled to BW. Thats because, these changes didnot come to RSA7 yet.

LBWQ
When changes happen in the source system, they get written to LBWQ .The delta entries, for the datasources of mode 'Queued Delta' get accumulated in LBWQ of the corresponsing queue . Each application component has a different Q. Below is a picture of LBWQ tcode


LBWE V3 Jobs
The way data comes to LBWQ is that, there will be V3 jobs running in the system, which help move the data from LBWQ to RSA7.The V3 jobs are scheduled to run every 15 mins or 30 mins depending on the company. Along with the scheduled job, we can also run the V3 jobs directly from LBWE - Job Control. Below are the V3 jobs in the system.
 1  RMBWV311         
 2  RMBWV312         
 3  RMBWV313         
 4  RMBWV302           
 5  RMBWV303            


Wednesday, February 10, 2016

some code

Getting Runtime
GET RUN TIME FIELD var_start.
PERFORM f_calculation.
GET RUN TIME FIELD var_end.
var_diff = var_end - var_start.
* Declare var_start.var_end as type 'i'. var_start would be 0 initially.


Getting the -ve number to the starting
var_csign TYPE /BIC/OITDATASOU .
CLEAR:var_csign.
var_csign = var_tranamt.
SEARCH var_csign FOR ‘-‘.
IF sy-subrc EQ 0 AND sy-fdpos NE 0.
SPLIT var_csign AT ‘-‘ INTO var_csign var_sign.
CONDENSE var_csign.
CONCATENATE ‘-‘ var_csign INTO var_csign.
ELSE.
CONDENSE var_csign.
ENDIF.
Notes: Change the datatype to CHAR

Hash Table
DATA :int_target TYPE HASHED TABLE OF y_target
WITH UNIQUE KEY
COMPANYCODE
CCTXTLG
ACCOUNT
ATXTLG
ERPID
ICP
ICPTXTLG
TRANSCURR
DATASOU
LCURR,
wa_target TYPE y_target. * Moving values to Hash Table to use Collect.
LOOP AT it_target INTO ls_target CLEAR:wa_target.
MOVE-CORRESPONDING ls_target TO wa_target.

Moving Field Symbol value to variable
data f1(4) value ‘ABC’.
DATA: v_val TYPE char4 VALUE ‘XYZA’.
field-symbols <f>.
assign f1 to <f>.

write<f>.
<f> = ‘ABD’.

Getting Source System
SOURCE_SYSTEM  = p_r_request->get_logsys( ).

Enabling/Disabling 3.X content
we made the value of one of the filed blank in RSADMINC table Value of field RSAWBN_HIDE_FUNC = ‘X’ in the table rsadminc table we made the value blank for that field this will enable the 3.x functionality

F4 Help code

INITIALIZATION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_obj-low.
  PERFORM f_help_object_class CHANGING s_obj.


*&---------------------------------------------------------------------*
*&      Form  F_HELP_OBJECT_CLASS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_P_OBJ  text
*----------------------------------------------------------------------*
FORM F_HELP_OBJECT_CLASS  CHANGING P_OBJ. " no definition of p_obj is required

TYPES BEGIN OF ty_tab,
        object TYPE CDOBJECTCL,
        obtext TYPE CDOBTEXT,
        END OF ty_tab.

DATA lt_tab TYPE STANDARD TABLE OF ty_tab,
       lt_ret TYPE STANDARD TABLE OF DDSHRETVAL,
       lw_ret TYPE DDSHRETVAL.


"" Here lt_tab is the data you want to see in the output of the F4 help. It is populated using a select statement.
            lt_ret is the standard table used for the FM

SELECT OBJECT OBTEXT from TCDOBT
              INTO TABLE lt_tab
             WHERE spras 'EN'.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  EXPORTING
*   DDIC_STRUCTURE         = ' '
    RETFIELD               'OBJECT'    " This is the field name defined in the internal table you want to see in the output.
    VALUE_ORG              'S'           " This is standard. 'C' or 'S' can be used. C didnot work.So 'S' :P
* IMPORTING
*   USER_RESET             =
  TABLES
    VALUE_TAB              lt_tab
    RETURN_TAB             lt_ret
 EXCEPTIONS
   PARAMETER_ERROR        1
   NO_VALUES_FOUND        2
   OTHERS                 3
          .

IF SY-SUBRC EQ 0.
  READ TABLE lt_ret INTO lw_ret INDEX 1. " Index 1 is the data row you have selected once the pop up for the F4 help opens. The selected value is present in 'fieldval' field
  p_obj lw_ret-fieldval.
ENDIF.


ENDFORM.                    " F_HELP_OBJECT_CLASS


Monday, February 8, 2016

Equipment

Tables
EQUI


Tcode
IE01/02/03


Notes 
When initializing 0equipment_attr, it needs to be 'Initialize WITH data transfer' - if it is WITHOUT, the delta will not be set in RSA7. The entry can seen, but no pointer value is present.

Enabling Delta for 0Equipment

In earlier versions,  0Equipment_Attr and 0Equipment_Text are not delta enabled by default.
Below Notes help in enabling them

2007055 - Delta for BW Extractor 0EQUIPMENT_ATTR
2007893 - Delta for BW Extractor 0EQUIPMENT_TEXT


Common Issues/Points to Remember


  • Infopackage Failures / Initialization Errors
    • Refer to this LINK

APD Related Errors

APD Lines missing in BW
This is due to SAP GUI update to 7.4. Refer SAP notes 2227956 ( did not work for me )


PSA Related Errors

PSA Deletion : Invalid DataStore object name /BIC/BXXX: Reason: No valid entry in table RSTS
Take the /BIC/ table name and open in SE11. Look for the datasource name in the description of the table and activate the datasource.

Bex Errors

When running analyzer, " Field symbol has not been assigned " 
The query does not throw any error but when analyzer is run, you get the field symbol error. There might be various reasons for this error , but in my case, the query I was working with had more than 50 fields as drill down and the query was not able to display it. Once the number of columns are reduced the error got away.
When running in RSRT, instead of using 'ABAP BICS' in the drop down for query display use LIST and run it. It will give you the message "  AMaximum number (50) of drilldown characteristics is exceeded" This is in my case.

Master Data Related Errors

Attributes of characteristic ZMASTER are locked by terminated change run 983212345
Lock NOT set for: Loading master data attributes
In Tcode : CHANGERUNMONI, you can see the status of the change run . 
Get the ID from there and run FM 'RSDDS_AGGR_MOD_CLOSE' to close/cancel the run.


Process Chain Related

Process Chain Triggering not triggering from event
When triggering process chain with event, the PC should be triggered manually first. this will schedule the chain for the run. Without that, even though the event is triggered, the process chain will run.

 Transport Errors

Start of the after-import method RS_TRFN_AFTER_IMPORT for object type(s) TRFN ( )
No mapping in RSLOGSYSMAP for source system <source system name>
Whenever there is a new source system mapping being added to the system, eg: a new source connection in UD Connect, entry needs to be maintained in table RSLOGSYSMAP. Once the entry is maintained, re-import the transport and it will go fine.

Error when creating transfer structure /BIC/CCQD0MATERIAL_ATTR in source system QECC100
Error when activating DataSource 0MATERIAL_ATTR QECC100
Error when creating transfer structure /BIC/CCQD0MATERIAL_ATTR in source system QECC100
Error when resetting DataSource 0MATERIAL_ATTR QECC100 to the active version
Install SAP Note 2524663 which actually needs implementation of Note 2214733
This note would create a new program ''RS_SCRSYSTEM_R3_CHECK' in the source system.
Run the program which in check mode 'NO_DB_UP = 'X'' and it will show you the inconsistent datasources.
Run the program with  'NO_DB_UP = ' ' and this would correct the datasources.
Re-import the transport and it should be fine.
This error might also occur when activating the datasource in BW system.

Transport fails in ChaRM with error "requests do not match the component version of the target system"
This is due to component mismatch in the system. (System - Staus - Product Version )
Refer SAP Note 1848094.
In the Options tab, click 'Ignore Invalid Component Version' option and import the transport.

DSO Related Errors

Values like Amounts, Quantities disappear after activation
If the fields are being populated in routines, then they must be make INITIAL in the transformation. Else. the values will not be updated in the DSO.


ECC Errors related to BW

V3 Jobs failure : Internal session terminated with a runtime error MESSAGE_TYPE_X
This can be because the LIS structure was changed, where there are entries present in LBWQ. The only way is to delete LBWQ entries and re-run the V3 job. Deleting LBWQ entries result in missing delta entries.
So whenever this is done, a FULL load needs to be done.


Struct. from appl. 03 due to open V3 proc. not changed -> Long text 
When adding new fields to the extractor, you might get the error.
This is because there are some unprocessed V3 entries or failed jobs which locked the structure. Check with ECC team for this or check SM13.
This mostly occurs in development ( as prod systems donot have failed jobs hanging around long). Once the locks are deleted, you can change the strucuture and the transport also goes fine between systems.

ABAP Programming Errors

The column name "MATNR" is ambiguous ABAP/4 Open SQL statement.
This occurs when using joins in a select statement.
This means that when using joins in select statement, same field is present in more than one table being used. If you are using a prefix for each table involved , you do not see this error. Else, use prefix '~' to mention which take the field needs to be read. 

SM30 Jobs running Long

Jobs are running very long.
There are many reasons for that . Some of the areas to check are listed below.
Check if there are any locks on table BALDAT.

Saturday, February 6, 2016

Material


There are materials with different types of Special Stocks.

Special Stock with Customer
Any material which is at customer end will fall under this. The quantities are saved in table MSKU.
SOBKZ = 'W'


Special Stock with Vendor
Materials/ inventory consigned to a vendor. They are saved in MSLB and MSSL.
SOBKZ = 'O'

Related Tcodes 
MB59

Related Notes
Stock Tables and Types : LINK

Datasource
0MATERIAL_ATTR/TEXT             Material Number
0MAT_PLANT_ATTR/TEXT          Material Number with Plant
0MAT_SALES_ATTR/TEXT          Material number with sales
0MAT_ST_LOC_ATTR                   Material Number Compounded to Plant and Storage Location

T-Codes :
MM01/2/3

Tables : 
MARA,MARC,MARD

0MAT_PLANT_ATTR/TEXT
  • This is Plant Data for Material.
  • Base table for this datasource is MARC
  • In MM03, there is tab which says 'Plant Stock'. Most of the fields from this datasource are present there.
  • Delta  : Create date/Change data in MARA table ( I guess ).

0MAT_ST_LOC_ATTR/TEXT
  • This is Storage Location Data for Material.
  • Base table for this datasource is MARD
  • In MM03, there is tab which says 'St.Loc Stock'. Most of the fields from this datasource are present there.
  • Delta  : Create date/Change data in MARA table ( I guess ).
0MAT_SALES_ATTR
  • This is Sales Data for Material. It is company code ( Sales Organization ) level.
  • Base table for this datasource is MVKE.
  • MM03 - Sales Org Tab

Master Data Datasources

Datasources

Master Data Datasources

Datasource

Description

Tables

Notes

0GL_ACCOUNT_ATTR G/L Account NumberSKA1 :G/L Account Master (Chart of Accounts)
0EMPLOYEE_ATTREmployeeSAP Help Link

Delta for Master data datasources. : Click here




Selection Screen

Standard Reference Program : CHANGEDOCU_READ

Structure of a program
Report Heading : REPORT  <Zprogram> MESSAGE-ID <ZMessage Class> 
Message Class can be created in SE91
SELECTION-SCREEN
Different blocks of selection screen can be defined here.
INITIALIZATION
AT SELECTION-SCREEN Options like F4 Help for the selection screen options
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN
here validations, authorizations are done
START-OF-SELECTION
Actual processing of data


Selection Screen block with select options and parameters
SELECTION-SCREEN BEGIN OF BLOCK sel WITH FRAME TITLE text-sel.
SELECT-OPTIONS:
  s_obj          FOR cdhdr-objectclas,
  s_obid         FOR cdhdr-objectid,
  s_chnr         FOR cdhdr-changenr.
PARAMETERS: p_user  LIKE cdhdr-username.
SELECTION-SCREEN END OF BLOCK sel.


Selection screen based on Radio button
type-pools: icon.
data: switch.
selection-screen begin of block b2 with frame title text-001.
parameters: radio radiobutton group rnd user-command test default 'X',
            radio2 radiobutton group rnd.
selection-screen end of block b2.
selection-screen begin of block b1 with frame title text-001.
parameters:
           test type bkpf-belnr modif id sc1.
selection-screen end of block b1.
selection-screen begin of block b3 with frame title text-001.
parameters:
           test1 type bkpf-belnr modif id sc2.
selection-screen end of block b3.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
  IF SCREEN-GROUP1 = 'SC1' AND RADIO EQ 'X'.
    SCREEN-ACTIVE = '0'.
    MODIFY SCREEN.
    CONTINUE.
  ELSEIF SCREEN-GROUP1 = 'SC2' AND RADIO2 EQ 'X'.
    SCREEN-ACTIVE = '0'.
    MODIFY SCREEN.
    CONTINUE.
  ENDIF.
ENDLOOP.

start-of-selection.

Selection screen options in one line / options side - by - side

This option does not work with dynamic selection screen based on radio button
SELECTION-SCREEN BEGIN OF BLOCK func WITH FRAME TITLE text-t06.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : p_dso RADIOBUTTON GROUP g1 USER-COMMAND comm DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(20) text-t01 FOR FIELD p_dso.
PARAMETERS :    p_wdso RADIOBUTTON GROUP g1.
SELECTION-SCREEN COMMENT 30(20)  text-t02 FOR FIELD p_wdso.
PARAMETERS :    p_md RADIOBUTTON GROUP g1.
SELECTION-SCREEN COMMENT 60(25)  text-t03.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK func.

 CHECK BOX

USING TOP

To have the extra top screen in the output of your ALV output

Data Declaration

DATA: lt_top TYPE slis_t_listheader,
             lw_top TYPE slis_listheader,

Populating Tables
  lw_top-typ 'S'.
  lw_top-key '<text>'.
  lw_top-info = <text>.
  APPEND lw_top TO lt_top.

using in ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_CALLBACK_TOP_OF_PAGE            'TOP'
Uncomment 'I_CALLBACK_TOP_OF_PAGE ' in the ALV output and have 'TOP' as value

Form
FORM f_top.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
     it_list_commentary       lt_top.
ENDFORM.

Have the above form in the system even though it does not have a perform. just have the form copy paste.


Creating documentation 
In SE38 -> Documentation
This should give the documentation maintained for the program. If there is no documentation, you can click on create

You might get the following error when maintaining documentation.
Document is not available in language EN
Check in the program header, if message id is included.
The first line of the program should be
REPORT ZTEST MESSAGE-ID Z001.

You can either add the statement and click on Z001 ( or whatever you named it ) and create the message ID or go to se91 and create it. You need not add any messages over there.
Once the 'Message ID' is included in the code, GoTo Documentation . It open a word document. Edit it and save.

Now on you can see the documentation and can edit it whenever needed.


Table Manipulations



  • Deleting all records from database table
DELETE FROM <ztable-name>.
DELETE FROM <ztable-name> WHERE <field-name> EQ 'condition'.

  • Adding new records to an empty database table
If you are inserting new records, always use insert. When I used update, it didnot work.
LOOP AT lt_equip INTO lw_equip.
  INSERT ZEQUIP_SERNO FROM lw_equip.
CLEAR lw_equip.
ENDLOOP.
IF sy-subrc EQ 0.
     COMMIT WORK.

  ENDIF.

  • Update and Modify
Update means it is only modify the record.
UPDATE <Table> FROM <work_area>.
Modify means it going to modify the record if it exists. If record is not there it going to add that record. 
  • Commit Work
Commit work is needed to commit the changes to table immediately. The commit can be placed inside the after each insert, but it takes lot more time.
https://scn.sap.com/thread/157718



Friday, February 5, 2016

ALE Delta and Change Pointers

Master data Delta mechanism
Master data delta explained

Change Pointers
ROOSGEN :
MSGTYP will give you the message type for that datasource. Taking an example of 0MAT_PLANT_ATTR : in production it has MSGTYP = RS0011

BD50 Or table TBDA2
we can see if the MSGTYPs are active.

BD52
Here we can see all 'Change document items' which are maintained for this Message Type. Only the fields where 'change document' checked in the dataelement can be present here.[ It also doesn't mean all the fields in the table where the change document is checked will be present. They need to be maintained, I GUESS ].

BD61
Activate Change Pointers Generally

TBD62
'Assignment of change document field to message type' can be seen. [I GUESS it kind of gives the same information as BD52, but in a tabular form . In this table, for the same 'Object Class' and 'Table Name' we find different Message Types.
For example, I am looking for 0MAT_PLANT_ATTR-TRAME and UMLC fields, which are from MARC table. Both of them have Change Documents enabled, but I am not seeing the delta picking up change in the fields. When I look into TBD62, I find entries for TRAME with Object class 'MATERIAL' Table 'MARC' , but they have different Message Class than RS0011. There are no entries for Message Class RS0011 for TRAME.I am ASSUMING that is the reason it is not picking up delta for these fields.

Re-running a failed Master data delta
How to Request a Failed Delta
Because the process indicators have been set to X, and there is nothing in RSA7, how do you request a failed delta.
The solution is to run program RSA1BDCP in the source system.
The ABAP does not validate the selection screen, as such I strongly advise you to validate and fill in all fields.
If a field is left blank, all data will be reset and thus your next delta will be a bit larger than intended!
This ABAP will reset the process indicator field on BDPCS to blank from a given data forward.
The process therefore to request a failed delta is:
  • Set the incorrect infopackage to green
  • Run RSA1BDCP for a date greater than the last successful delta
  • Rerun the delta infopackage




Links to refer




ECC Concepts