SAP Abap programming & SAP Modules SD,MM,HR,PP...
Search this site
Saturday, April 2, 2011
Read and write file in SAP ABAP
Function module
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwlGhxIrsODE_AuBL9pnMUlNKjKpFiGw-oeCNJmvHIs9WYe6Z5T8-yJw0OR7b5HHh1PRwJUyvLdADOmJGQSs1FvXbZH3g_6ETMQnJh3_Wi6fOrnvKrpiO0Otvm6eySzLHhOmP6_6SI9oc/s320/01.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGyCNIAkbfIWHC8QzZxa2DTrpJX4O7JAuG9EU4dHI0XcM5-G0YRkcV1bf7ppuxG9rcqinyuQkJh4v9dgaE4JrJydZdhOwssor73dAOZpHiqhPbwzq7z0c0eJJDtAifwYpTXY7Ory4TRMQ/s320/02.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaWXMocY7p9zORCtgyl-D-fbpQ0J_fRZdvsw_OmAzx6teSTBNmBZk50vCkr4Lj3CmT0ItmQm2_c2jprpFLQwkkvc3zDJ3fWyIGZrqTpRzGkoUxyCMk3Hghgi5hdfo2eWJn8LWp-m1cCX0/s320/03.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKdOFUAJX2q7H6ecC_xtdwreJOy6SA2-1B3YiD4JXCJwVZ0JM7oxg5zwHNhFDfVElv1AIW_SkF-BsaIbyKd0k4yOWWwn-dx9oEiVeYcT_7Q1GFtbzd1psLt0_wblQMFaUYWiX76avUMS4/s320/04.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3cpfnGEgrD4xUJ46IJuVZCR5B95Iw8VtMol8YvSeO43NbqVXMAzhzDIadGXV7Av7cRDkHOHn2pQWYJUhHVebmk_uf9PMguqU-Eke_xOMYsQ1UMemJkBqeDaEfKNsTKCG86rXa-36VO3I/s320/05.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcYarRfs2EEnLBV6W8RXw6eMIz4yzGVqq9eUscn-i43rlR4y4go3jJn4iSaza4hyphenhyphengxFRjY3SPLr633ch85j8mGcD_TwNLPtYD5XqkZkz_iXFC6YHxmP9cXQTwmUYTWCgC60nbkQWlgw00/s320/06.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyZ5LVz02gUsDx5u4zv0BonybBl1W5PfW_DUbOn3HUD8Wgx3Kgu2h2jk_wJVtJffP851vQxDJfgHjZM12B9BOX4Q9cy5MuNI8d11ADr9Auu3-RjQOfRyRPFdkJw4w7NSOVWajFlNTm1Gc/s320/07.png)
Friday, April 1, 2011
Subroutines
Include Programs
Using Include Programs
***INCLUDE ZTEST_INC.
WRITE: / 'Program started date:', SY-DATUM.
We can then include this program in any other ABAP program to display a standard list header.
PROGRAM ZTEST.
INCLUDE ZTEST_INC.
-------------------------------
The result:
Program started
date: 04/01/2011
Include Programs
Using Include Programs
***INCLUDE ZTEST_INC.
WRITE: / 'Program started date:', SY-DATUM.
We can then include this program in any other ABAP program to display a standard list header.
PROGRAM ZTEST.
INCLUDE ZTEST_INC.
-------------------------------
The result:
Program started
date: 04/01/2011
Macros
REPORT demo_mod_tech_macros.
DATA: result TYPE i,
n1 TYPE i VALUE 5,
n2 TYPE i VALUE 6.
DEFINE operation.
result = &1 &2 &3.
output &1 &2 &3 result.
END-OF-DEFINITION.
DEFINE output.
write: / 'The result of &1 &2 &3 is', &4.
END-OF-DEFINITION.
operation 4 + 3.
operation 2 ** 7.
operation n2 - n1.
This produces the following output:
The result of 4 + 3 is 7
The result of 2 ** 7 is 128
The result of N2 - N1 is 1
In this example, the two macros operation and output are defined. output is nested in operation. operation is called three times with different parameters. Note how the placeholders &1, &2,... are replaced in the macros.
Check a string is number or not
REPORT Z_TEST.
LW_CREDIT_TEMP TYPE BSEG-DMBTR.
PARAMETER: p_input TYPE char14.
FIND ALL OCCURRENCES OF ',' IN p_input MATCH COUNT count.
Write: ' occurance of the , = ', count.
IF p_input CO '1234567890, ' and count <= 1.
WRITE: /'Yes, valid', p_input.
write: lw_credit_temp.
Else.
WRITE: /'invalid', p_input.
write: lw_credit_temp.
ENDIF.