SAP R/3
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
- thitima's blog
- Add new comment
- Read more
- 1725 reads
Example to apply DO statement in ABAP/4
You will apply this statement when you want to loop data with non-condition loops.
Example 1: Simple Loop
DO.
WRITE:/ sy-index.
IF sy-index = 4.
EXIT.
ENDIF.
ENDDO.The output is
1
2
3
4
Example 2: Loops with n times
DO 4 TIMES.
WRITE:/ sy-index.
ENDDO.The output is same as example 1.
Example 3: Nested Loops
- thitima's blog
- Add new comment
- Read more
- 1160 reads
Difference between CONTINUE, CHECK and EXIT statement in ABAP/4
-
CONTINUE
When you apply this statement, system will pass a current loop. System ignores any statements after CONTINUE statement and start to the next loop.
Example
DO 4 TIMES.
WRITE:/ sy-index.
IF sy-index <= 2.
CONTINUE.
ENDIF.
WRITE: ’After’.
ENDDO.
The output is
1
2
3 After
4 After
-
CHECK
This statement will apply if you want to check condition before go to next statement. If the result of checking is ’TRUE’, system will go to next step as normally. If the result of checking is ’FALSE’, system will operate look like CONTINUE statement.
Example
- thitima's blog
- Add new comment
- Read more
- 16327 reads
Example to apply WHILE statement in ABAP/4
You will apply this statement when you want to loop data with condition loops.
Example 1: Simple Loop
DATA: lv_int TYPE I VALUE 1.
WHILE lv_int <= 4.
WRITE:/ lv_int.
lv_int = lv_int + 1.
ENDWHILE.
The output is
1
2
3
4
Example 3: Nested Loops
DATA: lv_int TYPE I VALUE 1,
lv_int2 TYPE I.
WHILE lv_int <= 4.
WRITE:/ lv_int.
lv_int2 = 1.
WHILE lv_int2 <= 2.
WRITE: lv_int2.
lv_int2 = lv_int2 + 1.
ENDWHILE.
lv_int = lv_int + 1.
ENDWHILE.
The output is
- thitima's blog
- Add new comment
- Read more
- 3771 reads
Select...Where & Select...Check in ABAP/4
Select...Where
SELECT * FORM SPFLI
WHERE CARRID = ’LH’.
...
...
...
ENDSELECT.
Select...Check
In above logic, Select...Where is better than Select...Check because the database can then user an index and system resource load is considerably less.SELECT * FORM SPFLI.
CHECK SPFLI-CARRID = ’LH’.
...
...
...
ENDSELECT.
- thitima's blog
- Add new comment
- 1204 reads
SELECT...INTO TABLE & SELECT...APPEND in ABAP/4
Select...Into Table
DATA: itab LIKE SPFLI OCCURS 0 WITH HEADER LINE.
SELECT * FORM SPFLI INTO TABLE itab.
Select...Append
In above logic, Select...Into Table is faster than Select...Append.DATA: itab LIKE SPFLI OCCURS 0 WITH HEADER LINE.
SELECT * FORM SPFLI INTO itab.
APPEND itab.
ENDSELECT.
- thitima's blog
- Add new comment
- 5664 reads
Recent comments
3 years 33 weeks ago
3 years 38 weeks ago
3 years 39 weeks ago
3 years 39 weeks ago
3 years 40 weeks ago
3 years 42 weeks ago
3 years 42 weeks ago
3 years 42 weeks ago
3 years 42 weeks ago
3 years 43 weeks ago