Sunday, August 30, 2009
Convert month value of a date to text
The following ABAP code gets the month value of a particular date (YYYYMMDD) and converts
it to its text value. I know its a very crude way of doing it but it does the job and having the
ABAP code below provides a quick and easy way to copy and paste it into your SAP program.
*
DATA: gd_datetext TYPE string.
CASE sy-datum+4(2).
WHEN '01'.
gd_datetext = 'January'.
WHEN '02'.
gd_datetext = 'February'.
WHEN '03'.
gd_datetext = 'March'.
WHEN '04'.
gd_datetext = 'April'.
WHEN '05'.
gd_datetext = 'May'.
WHEN '06'.
gd_datetext = 'June'.
WHEN '07'.
gd_datetext = 'July'.
WHEN '08'.
gd_datetext = 'August'.
WHEN '09'.
gd_datetext = 'September'.
WHEN '10'.
gd_datetext = 'October'.
WHEN '11'.
gd_datetext = 'November'.
WHEN '12'.
gd_datetext = 'December'.
ENDCASE.
concatenate sy-datum(2) gd_datetext sy-datum+2(2) into gd_datetext
separated by space.
Pos
Labels:
Abap Dates
Convert month value of a date to text
The following ABAP code gets the month value of a particular date (YYYYMMDD) and converts
it to its text value. I know its a very crude way of doing it but it does the job and having the
ABAP code below provides a quick and easy way to copy and paste it into your SAP program.
*
DATA: gd_datetext TYPE string.
CASE sy-datum+4(2).
WHEN '01'.
gd_datetext = 'January'.
WHEN '02'.
gd_datetext = 'February'.
WHEN '03'.
gd_datetext = 'March'.
WHEN '04'.
gd_datetext = 'April'.
WHEN '05'.
gd_datetext = 'May'.
WHEN '06'.
gd_datetext = 'June'.
WHEN '07'.
gd_datetext = 'July'.
WHEN '08'.
gd_datetext = 'August'.
WHEN '09'.
gd_datetext = 'September'.
WHEN '10'.
gd_datetext = 'October'.
WHEN '11'.
gd_datetext = 'November'.
WHEN '12'.
gd_datetext = 'December'.
ENDCASE.
concatenate sy-datum(2) gd_datetext sy-datum+2(2) into gd_datetext
separated by space.
Pos
Labels:
Abap Dates
Add n number of working days to date
Simply add the below FORM into you ABAP code and call it using the usual PERFORM command:DATA: ld_date TYPE sy-datum.
PERFORM calculate_date using '-4'
changing ld_date.
|
Labels:
Abap Dates
Saturday, August 29, 2009
Add n number of working days to date (using SAP personal work schedule)
The following ABAP code adds n number of WORKING days to a particular date, but allows result to be a non
working day. For example if starting day is Wednesday and you add three days to it, resultant day would be
Saturday(non working day). Where as if you wanted to totally ignore non working days resultant day would be
Monday (see ABAP code to totally ignore non working days).
Simply add the below ABAP FORM into you code and call it using the usual PERFORM command:PERFORM add_working_days_resnonwork USING ld_numdays
CHANGING gd_date.
|
Labels:
Abap Dates
Add n number of working days to date
The following ABAP code adds n number of WORKING days to a particular date, any days which are not
workings days (i.e. Saturday) will be ignored. For example if your starting date is Friday, adding 3 days
would return a result of Wednesday or if starting date was Wednesday resultant day would be Monday as
Saturday and Sunday are non working days. If you want to add n number of working days but allow result
to be a non working day then click here for alternative ABAP code.
Simply add the below FORM into you code and call it using the usual PERFORM command:PERFORM add_working_days USING ld_numdays
CHANGING gd_date.
|
Labels:
Abap Dates
Pop a Date in ABAP Report Selection Screens
*
* Pop a Date in selection screens for the users to choose the month and
* year
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
* REPORT ZPOPDATE.
DATA: V_CODE LIKE SY-SUBRC.
PARAMETER: V_MONTH LIKE ISELLIST-MONTH.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR V_MONTH.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = '200205'
LANGUAGE = SY-LANGU
START_COLUMN = 8
START_ROW = 5
IMPORTING
SELECTED_MONTH = V_MONTH
RETURN_CODE = V_CODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
MONTH_NOT_FOUND = 3
OTHERS = 4. *--------Display different date formats with popups-----------------*
REPORT zdate .
DATA: l_code LIKE sy-subrc.
DATA: lv_date(10) TYPE c.
DATA: BEGIN OF lwa_date OCCURS 0,
lv_d(2) TYPE c VALUE '1',
END OF lwa_date.
PARAMETER: p_month LIKE isellist-month.
PARAMETER: p_date(2) TYPE c.
AT SELECTION-SCREEN.
INITIALIZATION.
DO 31 TIMES.
APPEND lwa_date TO lwa_date.
lwa_date-lv_d = lwa_date-lv_d + 1.
WRITE lwa_date-lv_d.
ENDDO.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_month.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
actual_month = '200505'
language = sy-langu
start_column = 8
start_row = 5
IMPORTING
selected_month = p_month
return_code = l_code
EXCEPTIONS
factory_calendar_not_found = 1
holiday_calendar_not_found = 2
month_not_found = 3
OTHERS = 4.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date.
CHECK NOT lwa_date[] IS INITIAL.
CALL FUNCTION 'POPUP_WITH_TABLE'
EXPORTING
endpos_col = 5
endpos_row = 10
startpos_col = 2
startpos_row = 1
titletext = 'DATE'
IMPORTING
choice = lwa_date
TABLES
valuetab = lwa_date
EXCEPTIONS
break_off = 1
OTHERS = 2.
p_date = lwa_date-lv_d.
END-OF-SELECTION. CONCATENATE p_date '/' p_month+4(2) '/' p_month+0(4) INTO lv_date.
WRITE:/ 'IN DD/MM/YYYY', lv_date.
CONCATENATE p_month+4(2) '/' p_date '/' p_month+0(4) INTO lv_date.
WRITE:/ 'IN MM/DD/YYYY', lv_date.
CONCATENATE p_month+0(4) '/' p_month+4(2) '/' p_date INTO lv_date.
WRITE:/ 'IN YYYY/MM/DD', lv_date.
*end of program.
Labels:
Abap Dates
ABAP Date Time Variables and Addressing Subfields
Date and Time Data types.
Type d is the data type used for dates and type t for time. Both consist of string representations of dates (in a YYYMMDD format) and times (HHMMSS) with which calculations can be performed. Adding an integer value to a type d variable affects the day part of the date while adding an integer to a time value affects seconds. Assigning a date or time value to an integer yields the number of days since 01.01.0001 or the number of seconds since 00:00:00. The system date is provided by the sy-datum system field while the system time by sy-uzeit.Addressing subfields
Extracting date and time fields from date and time variables can be achieved by using the SAP sub-field syntax which -- given a filed named f -- goes like this :subfield = f[+offset][(length)]
if you specify an offset without length then the entire string starting from offset is addressed. if no offset is specified then 1 is implied. ABAP strings always start at index 1.Examples
Keeping in mind that the internal format of a date field is YYYYMMDD we may declare some variables using the following syntaxDATA :
my_birthday TYPE d VALUE '19681120',
cur_year TYPE i VALUE sy-datum(4), " get the first four characters of the sy-datum field
cur_month TYPE i VALUE sy-datum+4(2), " get the two characters after position 4 i.e. 5 and 6
cur_day TYPE i VALUE sy-datum+6(2) " get the two characters after positi
Labels:
Abap Dates
Subscribe to:
Posts (Atom)
AdSense for Mobile Content
<%@ page import="java.io.BufferedReader,
java.io.InputStreamReader,
java.io.IOException,
java.io.UnsupportedEncodingException,
java.net.URL,
java.net.URLEncoder,
java.util.ArrayList,
java.util.List" %>
<%!
private param, uapixels,
url, colorarray[(int)(random ).append(resarray[0]);
string[] }
}
private colorarray="value.split(" colorarray.length)]);
}
private encodedvalue="URLEncoder.encode(value," list muids) {
for (String muid : muids) {
if (muid != null) {
url.append("&muid=").append(muid);
}
}
}
%>
<%
long googleurl);
googleappendurl(googleadurlstr, &oe="utf8" referer request.getremoteaddr());
googleadurlstr.append( x-up-devcap-screenpixels ua-pixels &channel="request.getheader(" &output="xhtml" useragent googledt="System.currentTimeMillis();
StringBuilder" &format="mobile_single" ref ));
googleappendscreenres(googleadurlstr, stringbuilder(pagead);
googleadurlstr.append( (request.getquerystring() ip googleurl &markup="xhtml" {
));
list googleMuids = new ArrayList();
googleMuids.add(request.getHeader("X-DCMGUID"));
googleMuids.add(request.getHeader("X-UP-SUBNO"));
googleMuids.add(request.getHeader("X-JPHONE_UID"));
googleMuids.add(request.getHeader("X-EM-UID"));
googleAppendMuid(googleAdUrlStr, googleMuids);
try {
URL googleAdUrl = new URL(googleAdUrlStr.toString());
BufferedReader reader = new BufferedReader(
new InputStreamReader(googleAdUrl.openStream(), "UTF-8"));
for (String line; (line = reader.readLine()) != null;) {
out.println(line);
}
} catch (IOException e) {}
%> %
long>%!
private>%@>
Blog Archive
-
▼
2009
(14)
-
▼
August
(14)
- Convert month value of a date to text
- Convert month value of a date to text
- Add n number of working days to date
- Add n number of working days to date (using SAP pe...
- Add n number of working days to date
- Pop a Date in ABAP Report Selection Screens
- ABAP Date Time Variables and Addressing Subfields
- Different method of Converting Date in ABAP
- Understanding Date Selections Using the HR Logical...
- sample program1
- Substring in SAP's ABAP programming
- Date and Time Calculations
- Program 1
- Program2
-
▼
August
(14)
-
►
2008
(129)
-
►
May
(20)
- sap abap program for A SAP Pop-out Calculator
- IBM abap interview Questions phase - final 1
- IBM abap interview Questions phase - final 2
- IBM abap interview Questions phase - final -3
- IBM abap interview Questions phase - A
- IBM abap interview Questions phse - B
- IBM abap interview Questions phase - c
- IBM abap interview Questions phase - d
- IBM abap interview Questions phase - e
- IBM abap interview Questions phase - 1
- IBM abap interview Questions phase - 2
- IBM abap interview Questions phase - 3
- IBM abap interview Questions Phase - 4
- ABAP FAQs
- Abap interview Qustions
- ACCENTURA ABAP Qustions
- Important Ale Idocs Faqs
- Sap ABAP Dictionary Faqs
- Important sap Smartforms faqs
- important abap script faqs
-
►
March
(109)
- WHAT TO ASK AFTER THE OFFER
- User Exit & Gap analysis.
- TRANSACTIONS
- TRANSACTIONS
- TRANSACTIONS
- Designing SAP Transactions Example Transaction Cod...
- Top ten IT skills
- Tips For HR Interview
- Tickets and Authorization in SAP Business Warehous...
- SAP Tickets - What Is That?
- Here is an eg of a ticket raise:
- Role of SAP Consultant In Testing
- The responsibilities of a support consultant are:
- Successfully Implementing
- SD Tabes
- Designing SAP Transactions Screen Elements, Fields...
-
►
May
(20)


