Tuesday, March 12, 2013

CREATING TABLE MAINTENANCE GENERATOR FOR A TABLE

FIRST  Lets create a database table with fields

MANDT
LIFNR
LAND1
NAME1

 GOTO  SE11

databasetable : zTmg.
click on CREATE.
give short description : Table for TMG.
Delivery class : A
Data browser/ table view maint : Display/maintenance allowed.

click on  Fields tab

(Mandt  check the key and initial  and dataelement give mandt
lifnr check the key and initial and dataelement give lifnr.)

fields      Dataelement
mandt     mandt
lifnr        lifnr
name1    name1_gp
land1      land1_gp

click on  Technical setings
It will ask to save and save it in a $tmp local package

Dataclass : APPLO
Size       : 0.

save , goback

Click on  EXTRAS----> Enhancement Category
click enter
choose can be enhanced . and click on copy.

now save, check, activate.


CREATING TABLE MAINTENANCE GENERATOR FOR A TABLE

lets create TABLE MAINTENANCE GENERATOR for the above table ZTMG.

Table Maintenance Generator is used only for customized tables not for standard tables.
It is basically used to update or delete records or to create new entries for the ztable .

open the  ztmg table   (se11) and then ..
Utilities----> TABLE MAINTENANCE GENERATOR


Authorization Group : &nc&
Function Group : Zfunctmg. ( SE37 you can create a function group)

Maintenance type : choose one step.

Click on Find screen numbers
choose propose screen numbers
enter
now click on CREATE button.
save it in $tmp Package and goback
save check and activate your table.

Now to Insert records or delete records.

Goto Transaction code : SM30

Table : Ztmg.

choose No restrictions.

Click on MAINTAIN.
then click on NEW ENTRIES.
And add the records
1 krish Land
save.

go and check the records in se11.( Utilities-->Table contents--->Display).
you can find them.










THE MAINTENANCE DIALOG FOR ZTABLE IS INCOMPLETE OR NOT DEFINED --ERROR

Goto transaction code SE54 then enter the table name for which you have created the Table Maintenance Generator.
Then choose Generated objects
And click on display.
It will show the table maintenance dialog you have generated for the table, if doesn't show then create the table maintenance generator again,

This Error usually occurs when you are creating Table Maintenance Generator, after clicking on Find screen numbers..people usually forget to press on the CREATE button (beside the Find screen numbers)
when you don't press on CREATE  button you are doing the whole procedure correctly  but not creating it, so the system is not creating the Table Maintenance Generator for that particular table. So when you goto
SM30 and try to maintain entries you will get this error.

Hope you understand.


Thursday, February 21, 2013

How to create a database table in SAP ABAP or Steps to create a database table

Creating a Database Table in SAP ABAP:

1.Enter Transaction Code : SE11 and press Enter.

(ABAP Dictionary Initial Screen will appear)

2.Select radiobutton Database Table and provide name for the database table you want to
    create.  Database Table :  Zstudenttable.
(lets create a student table , The table name can be 16 characters in length.)

3. Press on CREATE .

4.  Provide Short Description : Table to store  students yearly marks.

Delivery and Maintenance Tab
5. Delivery Class : C Customizing Table.
     {A  Application Table(master and transaction data) These are client specific table.}


The delivery class controls the transport of table data for installation, upgrade, client copy and
when transporting between customer systems. The delivery class is also used in the extended
table maintenance.

6. Data Browser/ Table view maint. :  Display/ Maintenance allowed.

7. Save it .and it will ask for Package : $TMP. and save it.

8.Click on Fields Tab

9. Field        Key        Initial               DataElement
 StudentId. (a tick mark will appear).    Zstudentid
     

              ( This is nothing but Primary Key , which ensures the uniques values for that field. every table should atleast have 1 Primary key field. )


              All the key fields of a table must be stored together at the beginning of the table. A non-key
field may not occur between two key fields.
            A maximum of 16 key fields per table is permitted. The maximum length of the table key is
255.
            If the key length is greater than 120, there are restrictions when transporting table entries.
             The key can only be specified up to a maximum of 120 places in a transport. If the key is
larger than 120, table entries must be transported generically.
            A table may not have more than 249 fields. The sum of all field lengths is limited to 1962
(whereby fields with data type LRAW and LCHR are not counted).
              Fields of types LRAW or LCHR must be at the end of the table. Only one such field is
allowed per table. There must also be a field of type INT2 directly in front of such a field. The
actual length of the field can be entered there by the database interface.


Initial : If we select it , it will take the respective values as below. otherwise the value is null.


Data type
Initial Value
ACCP, CHAR, CUKY, LANG, UNIT
” ”  space
CURR, DEC, FLTP, INT1, INT2, INT4, QUAN
0
CLNT
000
TIMS
000000
DATS
00000000
NUMC
00000... for field length <= 32
no initial value for field length > 32
LRAW, LCHR, RAW, VARC
no initial value

10.STEPS TO CREATE A DATA ELEMENT and DOMAIN

11. Double click on the Data Element that is : Zstudentid..

It will ask to save the table, Click on YES.

It will ask to create  Data Element. Click on YES.

Short Description : Data element for student id.

Domain : zstudentid. 

In order to  create DOMAIN Double click on Zstudentid.

it will ask to save the table , click on yes. and package : $Tmp  and Save.

and it will ask to create the Domain , Click on Yes.

Short Description : Domain for Zstudentid.

Data type : Char.
No. of chars : 3.

Now save, check Activate the domain.

Go back and save, check ,activate the data element.

Go back , Click on Technical Settings.

Data class : APPLO (depends on type of data)
Size Category : 0     ( this predefines the no. of records the table can hold).

Save. go back,  and    check. 

it will show error enhancement category

for this go back 
and Click on Extras----> enhancement category

and select radiobutton  can be enhanced.      and press enter.

now save, check and activate.

like this add additional fields and again save , check , and activate.

now if you want to add entries to the database table.

go to Utilities------> Table Contents-----> Create Entries.

provide the values and save

and go back.

go to   Utilities------> Table Contents----> display

it will display the data.

we have successfully created a database table.


















ENHANCEMENT CATEGORY FOR TABLE MISSING ERROR

when this error occurs go to  EXTRAS---Enhancement category
 and then choose options like  " can be enhanced"  you will not get the error.

Friday, June 15, 2012

Smartforms in sap abap

Smart forms are client independent (you can access the smartform from any client like 800, 810, 820....).
Each page has its own page format and can have background pictures and can be printed in colors.
Table painter is available so that you can print data in tabular format.
Paragraphs and Character formats are reusable . you can create them using smart styles.
Function module is generated automatically at the time of activating the Smartform.

Saturday, January 14, 2012

While Endwhile statement example in sap abap


REPORT demo_flow_control_while .

DATA: length     TYPE i VALUE 0,
      strl       TYPE i VALUE 0,
      string(30) TYPE c VALUE 'Test String'.

strl = strlen( string ).

WHILE string NE space.
  WRITE string(1).
  length = sy-index.
  SHIFT string.
ENDWHILE.

WRITE: / 'STRLEN:          ', strl.
WRITE: / 'Length of string:', length.

Do enddo statements in sap abap with example program


REPORT demo_flow_control_do .

* simple do

DO.

  WRITE sy-index.
  IF sy-index = 3.
    EXIT.
  ENDIF.
ENDDO.

SKIP.
ULINE.

* do n times

DO 2 TIMES.
  WRITE sy-index.
  SKIP.
  DO 3 TIMES.
    WRITE sy-index.
  ENDDO.
  SKIP.
ENDDO.

SKIP.
ULINE.

* varying

DATA: BEGIN OF text,
        word1(4) TYPE c VALUE 'This',
        word2(4) TYPE c VALUE 'is',
        word3(4) TYPE c VALUE 'a',
        word4(4) TYPE c VALUE 'loop',
      END OF text.

DATA: string1(4) TYPE c, string2(4) TYPE c.

DO 4 TIMES VARYING string1 FROM text-word1 NEXT text-word2.
  WRITE string1.
  IF string1 = 'is'.
    string1 = 'was'.
  ENDIF.
ENDDO.

SKIP.

DO 2 TIMES VARYING string1 FROM text-word1 NEXT text-word3
           VARYING string2 FROM text-word2 NEXT text-word4.
  WRITE: string1, string2.
ENDDO.