Programming

The structure of BDCDATA in ABAP/4

BDC is a method for transfer data in SAP. Data that you want it to be operated by BCD must have structure as bellows:

BDCDATA Structure


Field Name    Type     Description
PROGRAM CHAR(40) Program Name
DYNPRO NUMC(4) Screen No.
DYNBEGIN CHAR(1) Begin a screen (If yes then equal ’X’)
FNAM CHAR(132) Field Name
FVAL CHAR(132) Field Value

How to Operate with Internal table for Single Line in ABAP/4

If you want to operate work area with internal table, you can operate follow on below statements:

  • APPEND Statement: If you want to append work area to internal table, you can apply this statement.
    Example
DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
APPEND lw_bkpf TO it_bkpf.
  • COLLECT Statement: If attribute of character string is not equal with same field in your work area, this statement operate look like append statement. If attribute of character string is equal with same field in your work area, this statement operate add the value of numeric (P, F, I).
    Example
DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
COLLECT lw_bkpf INTO it_bkpf.
  • INSERT Statement: Insert statement is look like append statement, but you can specify the index that you want to insert.
    Example
DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
INSERT lw_bkpf INTO it_bkpf INDEX 3.
  • MODIFY Statement: You can modify the data line of internal table by this statement.
    Example
DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
MODIFY it_bkpf INDEX 2 FROM lw_bkpf.
  • DELETE Statement: You can delete the data line of internal table by this statement.
    Example
DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
DELETE it_bkpf INDEX 2.
DELETE it_bkpf WITH KEY BELNR = ’1000000001’.
  • READ Statement: You can access to the data line of internal table by this statement.
    Example

DATA: lw_bkpf LIKE BKPF,
it_bkpf TYPE TABLE OF BKPF WITH HEADER LINE.
...
...
READ TABLE it_bkpf INDEX 2 INTO lw_bkpf.

How to Assign Dynamic Fields using Filed-Symbols in ABAP/4

You can create field name in run time and assign the created name in your field-symbols by statement "ASSIGN ... TO ...".

Example


DATA: name(20),
lv_check(1).

DATA: BEGIN OF itab OCCURS 0,
fld1(4),
fld2(4),
END OF itab.
FIELD-SYMBOLS .
...
...
LOOP AT itab.
IF lv_check = ’X’.
name = ’ITAB-FLD1’.
ELSE.
name = ’ITAB-FLD2’.
ENDIF.
ASSIGN (name) TO .

You can get run time of your program by insert ABAP statement

If you want to know how much the run time of your program by insert ABAP statement, you can insert command "GET RUN TIME" in the top and bottom of program block and minus two times.

Example


DATA: time1 TYPE I,
time2 TYPE I,
runtime TYPE I.
GET RUN TIME FIELD time1.
.....
...program statement...
.....
GET RUN TIME FIELD time2.
runtime = time2 - time1.

How to comment in HTML

When you want to comment to your html file, the statement should be begin by "". Between your comment statement do not have "--".

Example

How to Find First Date and End Date of Period in ABAP/4

If you know year, month and fiscal year variant and you want to know the first date and end date of that period, you can apply function module "PERIOD_DAY_DETERMINE" in ABAP/4 to get them.

Example


CALL FUNCTION ’PERIOD_DAY_DETERMINE’
EXPORTING
I_GJAHR = ’2006’ "Year
I_MONAT = ’01’ "Month
I_PERIV = ’F2’ "Fiscal Year Variant

IMPORTING
E_FDAY = FIRST_DATE
E_LDAY = END_DATE
EXCEPTIONS