Friday, March 24, 2017

System Fields / Time Fields


SYST - ABAP System Fields

Sy-subrc  - Checking the rightness of a Statement
= 0 ; Success
= 4 ; Record Not Found

TimeZone
sy-timlo - Gives the timezone of the user : EST, CST 

Date
Sy-datum - Gives local date of the user

Time 
SY-UZEIT - Gives in Local time of the user

Getting Timestamp
lv_sys_timestamp TYPE timestampl.  -- Gives Timestamp with millisecods
lv_tstamp TYPE TZNTSTMPS            -- Gives Timestamp with YYYYMMYYHHMMSS

GET TIME STAMP FIELD lv_sys_timestamp.
This gives the timestamp in UTC format.

Wednesday, March 22, 2017

using RANGE tables

(i)Using the data element you are looking for
    DATA : lt_bsart    TYPE RANGE OF ESART,
                 lw_bsart    LIKE LINE OF lt_bsart,


(ii) Declare your internal table type : RSSDLRANGE

  l_t_range-sign   'I'.
  l_t_range-option 'BT'.
  l_t_range-low    = zlow_value.
  l_t_range-high   = zhigh_value
 Append l_t_range TO l_t_range

SIGN can include "I" Include "E" Exclude
OPTION can include "EQ" Equal To "BT" Between "CP" Contains Pattern

Thursday, March 16, 2017

Bill Of Materials BOM

To produce a product with different variants, you can create super Bill of Materials 
that has a list of components to manufacture different variants of a product

Own notes
One Material is made up different components at different levels which are materials them selves.
Like, A material called APPLE is has BOM which has components like seeds, skin, pulp which are also materials.
There can be different levels of BOM.
        Main Material
       /       |       \
      /        |        \
 L1M1   L1M2   L1M3
                        /    |  
                              /        |
                         L2M1   L2M2



Tables
MAST - Material to BOM Link
STPO   - BOM item


Function Module
BOM Explosion : CS_BOM_EXPL_MAT_V2

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
        EXPORTING
          CAPID                 = 'SD01' "Sales
          DATUV                 = SY-DATUM "System Date
          MEHRS                 = 'X' " MultiLevels
          MTNRV                 = <Material>
          STLAL                 = <Alternative BOM>
          STLAN                 = <BOM Usage>
          WERKS                 = <Planst>
        TABLES
          STB                   = <output table>
        EXCEPTIONS
          ALT_NOT_FOUND         = 1
          CALL_INVALID          = 2
          MATERIAL_NOT_FOUND    = 3
          MISSING_AUTHORIZATION = 4
          NO_BOM_FOUND          = 5
          NO_PLANT_DATA         = 6
          NO_SUITABLE_BOM_FOUND = 7
          CONVERSION_ERROR      = 8
          OTHERS                = 9.

Monday, March 13, 2017

Change Documents

There are changes happening in SAP system all the time. Be it Master data related changes or Transaction related. Wouldn't be nice if there is a way to see all the changes done to different objects in the system?
That is where 'Change Documents' come into picture. CDHDR and CDPOS contains information of all change documents in the system.

Tables
CDHDR : Change document header
CDPOS :  Change document items
TCDOB : Objects for change document creation

Std. Program :
RSSCD100 : Displays Change Documents

TCode 
SCDO : Change Change Document

Reading CDHDR and CDPOS Tables

Object Class
The values in this field are pre-defined values which SAP has assigned to different objects like Material, Equipment, Asset, Sales Order changes etc.
The Object class values can be found in table TCDOB.

For example
Sales Order has Object Class 'VERKBELEG'.
Go to TCDOB and give the table name where the object is found and it gives the corresponding Object class needed to read the table.
Same object class is present for different tables which are of same category.

Object ID
This field has the actual values of the object , like Material number = '000MAT001' etc.


Process
Whenver a change is done , a change document number is created for the change. CDHDR has the change document number header details and CDPOS the item level details.

Note
Not all changes, like some text changes trigger a  change document.

Helpful Links
https://blogs.sap.com/2012/02/13/change-documents-for-sap-objects/