Convert data to Proper Case
Is there a function module, etc. to help convert names, etc. from UPPER CASE to Proper Case existing within SAP already?
Hi Steve,
As far as i know i dont think SAP has a function module for that.
To convert given string go through this link which uses TRANSFER command.
[Converting to Upper or Lower Case|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb33a5358411d1829f0000e829fbfe/content.htm]
Its better you create a function module including this statement as shown in the above link and use it as per your requirement or directly use as stated in the above link.
Hope this would help you.
Regards
Narin Nandivada
Similar Messages
-
Convert UPPERCASE to Proper Case
Hi There,
I'm jsut wondering how you convert data from all UPPER CASE to Proper case meaning. The first letter of each word is UPPER CASE only.
First name is: Jennifer
Last name is: Walsh
ThanksJust be aware that it doesn't work correctly for every name. For example, Lex de Hann would not be capitalized correctly.
SQL> create table employee(
2 fname varchar2(30),
3 lname varchar2(30)
4 );
Table created.
SQL> ed
Wrote file afiedt.buf
1* insert into employee values( 'JENNIFER', 'WILLIAMS' )
SQL> /
1 row created.
SQL> ed
Wrote file afiedt.buf
1* insert into employee values( 'LEX','DE HAN' )
SQL> /
1 row created.
SQL> ed
Wrote file afiedt.buf
1* insert into employee values( 'TIM', 'O''REILY' )
SQL> /
1 row created.
SQL> select initcap( fname ),
2 initcap( lname )
3 from employee;
INITCAP(FNAME) INITCAP(LNAME)
Jennifer Williams
Lex De Han
Tim O'ReilyJustin -
Convert data in table to mix case
Hi All,
I have a table that contains data.
This table has to columns, an id and description.
I would like to update my table to convert data to mix case.
As of now, all of my data in the table are lower case.
What I mean by mix case is first letter for each word is uppercase and the rest are lower case.
is there a function i can use ?
example:
Amended/Resentence, Type UnknownThanksYou can use the INITCAP function.
update table
set description = INITCAP(description);Example:
create table test (description varchar(50));
Table created
insert into test values ('amended/resentence, type unknown');
1 row inserted
select * from test;
DESCRIPTION
amended/resentence, type unknown
update test set description = initcap(description);
1 row updated
select * from test;
DESCRIPTION
Amended/Resentence, Type Unknown -
What is the best way to load and convert data from a flat file?
Hi,
I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
What is the best and easiest way to archive this?
Thanks,
Carsten.Hi,
thanks for your answers so far!
I gave them a thought and came up with two different alternatives:
Alternative 1
I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
The columns of the staging table have the target format (date, number).
The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
Alternative 2
The columns of the staging table are all of type varchar2 regardless of the target format.
I define data rules for all columns that require a later conversion.
I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
The rows that cannot be loaded go automatically into the error table.
When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
Further, I would prefer using expressions in the mapping for converting the data.
What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
As far as I know I need the data quality option for using data rules, is that true?
Is there another alternative without any of these drawbacks?
Otherwise I think I will go for alternative 1.
Thanks,
Carsten. -
Conversion failed when converting date and/or time from character string
Hi experts,
I'm trying running a query in Microsoft Query but it gives the following error message:
"conversion failed when converting date and/or time from character string"
when asks me the data I'm inserting 31-01-2014
i've copy the query form the forum:
SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
CASE WHEN T0.TransType=13 THEN 'Invoice'
WHEN T0.TransType=14 THEN 'Credit Note'
WHEN T0.TransType=30 THEN 'Journal'
WHEN T0.TransType=24 THEN 'Receipt'
END AS 'Document Type',
T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
ORDER BY T1.CardCode, T0.DueDate, T0.Ref1Hi,
The above error appears due to date format is differnt from SAP query generator and SQL server.
So you need convert all date in above query to SQL server required format.
Try to convert..let me know if not possible.
Thanks & Regards,
Nagarajan -
SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string. 'Received Alerts' (OAIB)
SELECT
CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
WHEN T0.DocStatus = 'C' THEN 'CLOSED' END AS 'Document Status',
T0.DocDate AS 'Posting Date',
T0.DocNum AS 'Doc.No',
T0.NumAtCard,
T0.TransId AS 'Trans. No.',
T0.Comments AS 'Remarks',
T0.CardCode AS 'Offset Acct',
T0.CardName AS 'Offset Acct Name',
sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
T3.DueDate AS 'Cheque Date',
T3.CheckSum AS 'Amount'
FROM ODPO AS T0 LEFT OUTER JOIN
VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
VPM1 AS T3 ON T2.DocEntry = T3.DocNum
where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'Hi,
Try this:
SELECT
CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
WHEN T0.DocStatus = 'C' THEN 'CLOSED' END AS 'Document Status',
T0.DocDate AS 'Posting Date',
T0.DocNum AS 'Doc.No',
T0.NumAtCard,
T0.TransId AS 'Trans. No.',
T0.Comments AS 'Remarks',
T0.CardCode AS 'Offset Acct',
T0.CardName AS 'Offset Acct Name',
sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
T3.DueDate AS 'Cheque Date',
T3.CheckSum AS 'Amount'
FROM ODPO T0 LEFT OUTER JOIN
VPM2 T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
LEFT OUTER JOIN
OVPM T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
VPM1 T3 ON T2.DocEntry = T3.DocNum
where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
group by T0.DocStatus,T0.DocDate ,
T0.DocNum ,
T0.NumAtCard,
T0.TransId ,
T0.Comments ,
T0.CardCode,
T0.CardName ,
T0.WTSum ,
T3.DueDate ,
T3.CheckSum
Thanks & Regards,
Nagarajan -
Trying to use regular expressions to convert names to Title Case
I'm trying to change names to their proper case for most common names in North America (esp. the U.S.).
Some examples are in the comments of the included code below.
My problem is that *retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");* does not work as I expect. It seems that the toUpperCase method call does not actually do anything to the identified group.
Everything else works as I expect.
I'm hoping that I do not have to iterate through each character of the string, upshifting the characters that follow spaces.
Any help from you RegEx experts will be appreciated.
{code}
* Converts names in some random case into proper Name Case. This method does not have the
* extra processing that would be necessary to convert street addresses.
* This method does not add or remove punctuation.
* Examples:
* DAN MARINO --> Dan Marino
* old macdonald --> Old Macdonald <-- Can't capitalize the 'D" because of Ernst Mach
* ROY BLOUNT, JR. --> Roy Blount, Jr.
* CAROL mosely-BrAuN --> Carol Mosely-Braun
* Tom Jones --> Tom Jones
* ST.LOUIS --> St. Louis
* ST.LOUIS, MO --> St. Louis, Mo <-- Avoid City Names plus State Codes
* This is a work in progress that will need to be updated as new exceptions are found.
public static String toNameCase(String name) {
* Basic plan:
* 1. Strategically create double spaces in front of characters to be capitalized
* 2. Capitalize characters with preceding spaces
* 3. Remove double spaces.
// Make the string all lower case
String retName = name.trim().toLowerCase();
// Collapse strings of spaces to single spaces
retName = retName.replaceAll("[ ]+", " ");
// "mc" names
retName = retName.replaceAll("( mc)", " $1");
// Ensure there is one space after periods and commas
retName = retName.replaceAll("(\\.|,)([^ ])", "$1 $2");
// Add 2 spaces after periods, commas, hyphens and apostrophes
retName = retName.replaceAll("(\\.|,|-|')", "$1 ");
// Add a double space to the front of the string
retName = " " + retName;
// Upshift each character that is preceded by a space
// For some reason this doesn't work
retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");
// Remove double spaces
retName = retName.replaceAll(" ", "");
return retName;
Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:56 AM
Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:57 AMHopefully someone will still be able to provide a RegEx solution, but until that time here is a working method.
Also, if people have suggestions of other rules for letter capitalization in names, I am interested in those too.
* Converts names in some random case into proper Name Case. This method does not have the
* extra processing that would be necessary to convert street addresses.
* This method does not add or remove punctuation.
* Examples:
* CAROL mosely-BrAuN --> Carol Mosely-Braun
* carol o'connor --> Carol O'Connor
* DAN MARINO --> Dan Marino
* eD mCmAHON --> Ed McMahon
* joe amcode --> Joe Amcode <-- Embedded "mc"
* mr.t --> Mr. T <-- Inserted space
* OLD MACDONALD --> Old Macdonald <-- Can't capitalize the 'D" because of Ernst Mach
* old mac donald --> Old Mac Donald
* ROY BLOUNT,JR. --> Roy Blount, Jr.
* ST.LOUIS --> St. Louis
* ST.LOUIS,MO --> St. Louis, Mo <-- Avoid City Names plus State Codes
* Tom Jones --> Tom Jones
* This is a work in progress that will need to be updated as new exceptions are found.
public static String toNameCase(String name) {
* Basic plan:
* 1. Strategically create double spaces in front of characters to be capitalized
* 2. Capitalize characters with preceding spaces
* 3. Remove double spaces.
// Make the string all lower case
String workStr = name.trim().toLowerCase();
// Collapse strings of spaces to single spaces
workStr = workStr.replaceAll("[ ]+", " ");
// "mc" names
workStr = workStr.replaceAll("( mc)", " $1 ");
// Ensure there is one space after periods and commas
workStr = workStr.replaceAll("(\\.|,)([^ ])", "$1 $2");
// Add 2 spaces after periods, commas, hyphens and apostrophes
workStr = workStr.replaceAll("(\\.|,|-|')", "$1 ");
// Add a double space to the front of the string
workStr = " " + workStr;
// Upshift each character that is preceded by a space and remove double spaces
// Can't upshift using regular expressions and String methods
// workStr = workStr.replaceAll("( [^ ])([^ ]+)", "$1"toUpperCase() + "$2");
StringBuilder titleCase = new StringBuilder();
for (int i = 0; i < workStr.length(); i++) {
if (workStr.charAt(i) == ' ') {
if (workStr.charAt(i+1) == ' ') {
i += 2;
while (i < workStr.length() && workStr.charAt(i) == ' ') {
titleCase.append(workStr.charAt(i++));
if (i < workStr.length()) {
titleCase.append(workStr.substring(i, i+1).toUpperCase());
} else {
titleCase.append(workStr.charAt(i));
return titleCase.toString();
{code} -
Convert data is not writng anythng in LSMW?
Hi Friends,
After uplaoding the data, when I goto convert data step and execute. It reads 2 records but it doesn't write anything. So I am not able to execute the batch input method? I am doing that for Material master? Can any one help me regarding this. It would be of great help?
Thanks,
SAP ABAPerCheck in the 5th step (Field Mapping) is there any standard function '<b>skip_record</b>,<b>'skip_transaction'</b> by searching globally.
If any such standard function is there, check when exactly its triggering.
I think for your data conversion, those standard functions are triggering.
in this case only the data will not be converted, the conversion of the data does not depend on whether the data exists in the destination system or not.
Regards,
Rajinikanth -
How we can view convert data after XSLT mapping & before Graphical mapp
Hello Friends,
Currently i am working on XI standard content. In this client need some customization.
In interface mapping, XSLT mapping on 1st position & Graphical mapping on 2nd position.
As per my understanding 1st XSLT mapping will be exected then Graphical mapping.
Can I see or check convert data from XSLT mapping.
I want to check data between XSLT mapping & Graphical mapping.
Kindly help me out.
Regards,
Narendra>
Narendra GSTIT wrote:
> I dont want to test standalone XSL Code.
>
> The data which I get from Source interface and after XSLT mapping I want to check this that my XSLT code is going well or not.
>
> i.e. check for proper input & get proper output.
You have ro do standalone testing of the XSLT mapping.....Interface Mapping or Interface Determination will give you output message which will be that of message mapping (the last mapping)
What is the issue in testing the XSLT mapping alone?...may be in Stylus Studio.
Just ensure that XSLT mapping produces proper output and then this output message of XSLT is the input to your Message Mapping.....once the entire Interface mapping gets executed then it would mean that all the included mapping programs work fine.
Regards,
Abhishek. -
Convert data to MSWORD, MSEXCEL or PDF
Hi,
I have a requirement of sending SAP std report output as an attachment via email. I am thinking of using SUBMIT TO MEMORY or SPOOL and then get the data from there and convert and send as file attachment using SO_DOCUMENT_SEND_API1 or class CL_BCS. The file is required to be sent as MSWORD or MSEXCEL or PDF which can be decided by having a parameter on selection screen..
But I am not sure on how to convert data after retrieving it back from Memory or spool. There are a few function modules to convert. Can anyone give me the names please in each case like
For Spool to PDF function CONVERT_ABAPSPOOLJOB_2_PDF can be used
For Spool to Excel ?
For Spool to Word ?
For memory to PDF ?
For memory to Word ?
For memory to Excel ?
Regards,
VinHi,
I just had the same reuirement and i did it few days back . here is the code ...juz modify it accordingly.
The program will send my ABAP report as a PDF attachment to the USER>
REPORT ZRMM0055 NO STANDARD PAGE HEADING
MESSAGE-ID ZZ
LINE-SIZE 255
LINE-COUNT 65.
TABLES DECLARATION *
TABLES : MARD, " Storage Location Data for Material
MARC, " Plant Data for Material
MSEG,
SSCRFIELDS. " Fields on selection screens
Internal Tables declaration. *
*---Internal Table to hold the MARD table data
DATA : BEGIN OF IT_MARD OCCURS 0,
MATNR LIKE MARD-MATNR, " Material Number
WERKS LIKE MARD-WERKS, " Plant
LGORT LIKE MARD-LGORT, " Storage Location
LMINB LIKE MARD-LMINB, " Reorder Point
LABST LIKE MARD-LABST, " Stock at storage loc
END OF IT_MARD.
*---Internal table to hold data from MSEG, MKPF, MAKT
DATA : BEGIN OF IT_MSEG OCCURS 0,
MATNR LIKE MARD-MATNR, " Material Number
WERKS LIKE MARD-WERKS, " Plant
LGORT LIKE MARD-LGORT, " Storage Location
MENGE LIKE MSEG-MENGE, " Quantity
MEINS LIKE MSEG-MEINS, " UOM
LIFNR LIKE MSEG-LIFNR, " Account Number of Vendor
SHKZG LIKE MSEG-SHKZG, " Credit/Debit Indicator
EBELN LIKE EKPO-EBELN,
MENGE1 LIKE EKPO-MENGE, " Open PO qty
EINDT LIKE EKET-EINDT,
DISPO LIKE MARC-DISPO, " MRP controller
EKGRP LIKE MARC-EKGRP, " Purchasing Group
MAKTX LIKE MAKT-MAKTX,
END OF IT_MSEG.
*----Internal table to hold the data from EKPO and EKET table
DATA : BEGIN OF IT_EKPO OCCURS 0,
EBELN LIKE EKPO-EBELN, " PO document
EBELP LIKE EKPO-EBELP, " Item
MATNR LIKE MARD-MATNR, " Material Number
WERKS LIKE MARD-WERKS, " Plant
LGORT LIKE MARD-LGORT, " Storage Location
MENGE LIKE EKPO-MENGE, " Quantity
EINDT LIKE EKET-EINDT, " Delivery Date
END OF IT_EKPO.
*--Internal Table to hold the final data
DATA : BEGIN OF IT_FINAL OCCURS 0,
MATNR LIKE MARD-MATNR, " Material Number
MAKTX LIKE MAKT-MAKTX, " Material Description
LMINB LIKE MARD-LMINB, " Reorder Point
MEINS LIKE MSEG-MEINS, " UOM
LABST LIKE MARD-LABST, " On hand inventory at storageloc
TOT_LABST LIKE MARD-LABST, " Total On hand at plant
ISSUE LIKE MSEG-MENGE, " YTD issue
RECEIPT LIKE MSEG-MENGE, " YTD receipts
DISPO LIKE MARC-DISPO, " MRP controller
EKGRP LIKE MARC-EKGRP, " Purchasing Group
MENGE LIKE EKPO-MENGE, " Open PO Quantity
EINDT LIKE EKET-EINDT, " Next Delivery Date
LIFNR LIKE MSEG-LIFNR, " Vendor
EBELN LIKE MSEG-EBELN, " PO number
END OF IT_FINAL.
*----Internal table to hold YTD data
DATA : BEGIN OF IT_YTD OCCURS 0,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
SHKZG LIKE MSEG-SHKZG,
END OF IT_YTD.
DATA : BEGIN OF X_MSEG,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
MATNR LIKE MARD-MATNR, " Material Number
WERKS LIKE MARD-WERKS, " Plant
LGORT LIKE MARD-LGORT, " Storage Location
MENGE LIKE MSEG-MENGE, " Quantity
MEINS LIKE MSEG-MEINS, " UOM
LIFNR LIKE MSEG-LIFNR, " Account Number of Vendor
SHKZG LIKE MSEG-SHKZG, " Credit/Debit Indicator
EBELN LIKE EKPO-EBELN,
MENGE1 LIKE EKPO-MENGE, " Open PO Qty
EINDT LIKE EKET-EINDT,
DISPO LIKE MARC-DISPO, " MRP controller
EKGRP LIKE MARC-EKGRP, " Purchasing Group
MAKTX LIKE MAKT-MAKTX,
END OF X_MSEG.
DATA: V_LMINB(16) TYPE C,
S_LABST(16) TYPE C,
V_TOT_LABST(16) TYPE C,
S_ISSUE(16) TYPE C,
S_RECEIPT(16) TYPE C,
V_MENGE(16) TYPE C,
V_EINDT(8) TYPE C.
DATA: T_PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
VARIABLES DECLARATION *
DATA : V_SUM TYPE MSEG-MENGE, " Variable for adding GI's to Stock
V_TEMP TYPE MSEG-MENGE, " Variable for adding GI's to Stock
V_TABIX TYPE SY-TABIX, " Loop count
V_ISSUE LIKE MSEG-MENGE, " Variable for calculating YTD issues
V_RECEIPT LIKE MSEG-MENGE, " Var for Calculating YTD Receipts
V_LABST LIKE MARD-LABST, " Var for Total On hand inv at plant
V_MJAHR LIKE MSEG-MJAHR, " Variable for holding the Year
f_color.
*----Declaration to send Email
DATA: IT_PDF LIKE TLINE OCCURS 10 WITH HEADER LINE,
IT_XI_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE,
IT_HTML LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_XI_TEMP LIKE BAPIQCMIME OCCURS 0 WITH HEADER LINE,
IT_XI_MIME(255) TYPE C OCCURS 0 WITH HEADER LINE.
DATA:
LS_DOCDATA TYPE SODOCCHGI1,
LT_OBJPACK TYPE TABLE OF SOPCKLSTI1 WITH HEADER LINE,
LT_OBJHEAD TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
LT_OBJTXT TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
LT_OBJBIN TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
LT_RECLIST TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
LT_LISTOBJECT TYPE TABLE OF ABAPLIST WITH HEADER LINE,
LT_LISTOBJECTLN(1000) TYPE C,
L_TAB_LINES TYPE I,
L_ATT_TYPE LIKE SOODK-OBJTP.
DATA: IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
Internal table for Single List with Column Length 255
DATA : IT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
Internal table for Single List with Column Length 255
DATA : IT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
Internal table for Structure of the API Recipient List
DATA : IT_RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
Structure of the API Recipient List
DATA: X_DOC_CHNG LIKE SODOCCHGI1.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
P_WERKS LIKE MARD-WERKS OBLIGATORY. " Plant
SELECT-OPTIONS:
S_BUKRS for mseg-bukrs, " Company code
S_LGORT FOR MARD-LGORT OBLIGATORY, " Storage Location
S_MATNR FOR MARD-MATNR, " Material Number
S_DISPO FOR MARC-DISPO, " MRP Controller
S_DATE FOR SY-DATUM DEFAULT SY-DATUM OBLIGATORY. " Date Range
SELECTION-SCREEN END OF BLOCK S1.
SELECTION-SCREEN BEGIN OF BLOCK S2 WITH FRAME TITLE TEXT-002.
PARAMETERS:
P_MAIL TYPE C AS CHECKBOX. " Mail to user Group
SELECT-OPTIONS:
S_UNAME FOR SY-UNAME NO INTERVALS. " Usergroup id
SELECTION-SCREEN END OF BLOCK S2.
Initialization
INITIALIZATION.
AT S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN.
CHECK SSCRFIELDS-UCOMM EQ 'ONLI'.
PERFORM VALIDATE_MAIL.
PERFORM VALIDATE_DATA.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM FETCH_DATA.
END-OF-SELECTION *
END-OF-SELECTION.
IF NOT IT_FINAL[] IS INITIAL.
PERFORM DOWNLOAD_DISPLAY_REPORT.
ENDIF.
TOP-OF-PAGE *
TOP-OF-PAGE.
PERFORM PAGE_HEADER.
*& Form Fetch_DATA
Pick data
FORM FETCH_DATA .
DATA : V_EBELN LIKE EKPO-EBELN,
V_EBELP LIKE EKPO-EBELP,
V_MENGE LIKE EKPO-MENGE,
V_EINDT LIKE EKET-EINDT,
V_DISPO LIKE MARC-DISPO,
V_EKGRP LIKE MARC-EKGRP,
V_MAKTX LIKE MAKT-MAKTX.
*----Select data from MARD Table
SELECT MATNR " Material Number
WERKS " Plant
LGORT " Storage Location
LMINB " Reorder Point Level
LABST " Stock with unrestricted use
INTO TABLE IT_MARD
FROM MARD
WHERE MATNR IN S_MATNR AND
WERKS = P_WERKS . "AND
LGORT IN S_LGORT.
D~LMINB <> SPACE .
IF SY-SUBRC = 0.
LOOP AT IT_MARD.
CLEAR : V_EBELN, V_EBELP, V_MENGE, V_EINDT.
*---select data from EKPO table
SELECT EBELN
EBELP
MENGE
UP TO 1 ROWS
FROM EKPO
INTO (V_EBELN, V_EBELP, V_MENGE)
WHERE MATNR = IT_MARD-MATNR AND
WERKS = IT_MARD-WERKS AND
LGORT = IT_MARD-LGORT AND
BUKRS IN S_BUKRS AND
ELIKZ = SPACE.
ENDSELECT.
IF SY-SUBRC = 0.
X_MSEG-EBELN = V_EBELN.
X_MSEG-MENGE1 = V_MENGE.
SELECT EINDT
UP TO 1 ROWS
FROM EKET
INTO V_EINDT
WHERE EBELN = V_EBELN AND
EBELP = V_EBELP.
ENDSELECT.
IF SY-SUBRC = 0.
X_MSEG-EINDT = V_EINDT.
ENDIF.
ENDIF.
*---Select Data from MARC table.
CLEAR : V_DISPO, V_EKGRP.
SELECT DISPO
EKGRP
UP TO 1 ROWS
FROM MARC
INTO (V_DISPO, V_EKGRP)
WHERE MATNR = IT_MARD-MATNR AND
WERKS = IT_MARD-WERKS AND
DISPO IN S_DISPO.
ENDSELECT.
IF SY-SUBRC = 0.
X_MSEG-DISPO = V_DISPO.
X_MSEG-EKGRP = V_EKGRP.
else.
continue.
ENDIF.
*---select Material Description from MAKT
CLEAR V_MAKTX.
SELECT SINGLE MAKTX
FROM MAKT
INTO V_MAKTX
WHERE MATNR = IT_MARD-MATNR AND
SPRAS = SY-LANGU.
IF SY-SUBRC = 0.
X_MSEG-MAKTX = V_MAKTX.
ENDIF.
*----Select data from MSEG Table
SELECT MBLNR
MJAHR
MATNR " Material Number
WERKS " Plant
LGORT " Storage Location
MENGE " Quantity
MEINS " UOM
LIFNR " Account No of Vendor
SHKZG " Credit/Debit Indicator
FROM MSEG
INTO X_MSEG
WHERE MATNR = IT_MARD-MATNR AND
WERKS = IT_MARD-WERKS AND
LGORT = IT_MARD-LGORT AND
BUKRS IN S_BUKRS.
*---Subroutine to check whether the document is in the given date range
PERFORM CHECK_DATE.
ENDSELECT.
ENDLOOP.
ELSE.
STOP.
ENDIF.
*----Select YTD receipts and Issues to date from MSEG
CLEAR : V_MJAHR, V_ISSUE, V_RECEIPT.
IF S_DATE[] IS NOT INITIAL.
V_MJAHR = S_DATE+3(4).
ELSE.
V_MJAHR = SY-DATUM+0(4).
ENDIF.
SELECT MENGE
MEINS
SHKZG
FROM MSEG
INTO TABLE IT_YTD
WHERE WERKS = P_WERKS AND
MJAHR = V_MJAHR.
*--Calculating YTD receipts and Issues
IF SY-SUBRC = 0.
LOOP AT IT_YTD.
IF IT_YTD-SHKZG = 'S'.
V_ISSUE = V_ISSUE + IT_YTD-MENGE.
ELSE.
V_RECEIPT = V_RECEIPT + IT_YTD-MENGE.
ENDIF.
ENDLOOP.
IT_FINAL-ISSUE = V_ISSUE.
IT_FINAL-RECEIPT = V_RECEIPT.
ENDIF.
*-----Logic for printing the material
LOOP AT IT_MSEG.
V_TABIX = SY-TABIX.
AT NEW MATNR.
*----Logic for calculation of Total On hand inv at plant.
*---Sum of all MARD-LABST.
CLEAR V_LABST.
LOOP AT IT_MARD WHERE MATNR = IT_MSEG-MATNR.
V_LABST = V_LABST + IT_MARD-LABST.
ENDLOOP.
IT_FINAL-TOT_LABST = V_LABST.
ENDAT.
AT NEW LGORT.
CLEAR : V_SUM.
ENDAT.
READ TABLE IT_MARD WITH KEY MATNR = IT_MSEG-MATNR
WERKS = IT_MSEG-WERKS
LGORT = IT_MSEG-LGORT.
IF SY-SUBRC = 0 AND IT_MARD-LMINB > 0.
*---Logic for adding/Subtracting GR/GI
IF V_TABIX = 1.
IF IT_MSEG-SHKZG = 'S'.
V_TEMP = IT_MARD-LABST + IT_MSEG-MENGE.
ELSE.
V_TEMP = IT_MARD-LABST - IT_MSEG-MENGE.
ENDIF.
ENDIF.
IF IT_MARD-LABST < IT_MARD-LMINB. "Stock < Reorder Point
*---Check for any goods receipts on the given day. SHKZG = 'S'
IF IT_MSEG-SHKZG = 'S' .
IF V_TABIX = 1.
V_SUM = V_TEMP.
ELSE.
V_SUM = V_SUM + IT_MSEG-MENGE.
ENDIF.
IF V_SUM < IT_MARD-LMINB.
IT_FINAL-MATNR = IT_MARD-MATNR.
IT_FINAL-MAKTX = IT_MSEG-MAKTX.
IT_FINAL-LMINB = IT_MARD-LMINB.
IT_FINAL-MEINS = IT_MSEG-MEINS.
IT_FINAL-LABST = IT_MARD-LABST.
IT_FINAL-DISPO = IT_MSEG-DISPO.
IT_FINAL-EKGRP = IT_MSEG-EKGRP.
IT_FINAL-LIFNR = IT_MSEG-LIFNR.
IT_FINAL-ISSUE = V_ISSUE.
IT_FINAL-RECEIPT = V_RECEIPT.
IT_FINAL-TOT_LABST = V_LABST.
IT_FINAL-EBELN = IT_MSEG-EBELN.
IT_FINAL-MENGE = IT_MSEG-MENGE1.
IT_FINAL-EINDT = IT_MSEG-EINDT.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ELSE.
*--- If there is no Goods receipt mov't type on the given day, then
*---add all the goods issues to the storage location stock.
*---Goos Receipt = 'S' , Goods Issue = 'H'.
IF V_TABIX = 1.
V_SUM = V_TEMP.
ELSE.
V_SUM = V_SUM - IT_MSEG-MENGE.
ENDIF.
IF V_SUM < IT_MARD-LMINB.
IT_FINAL-MATNR = IT_MARD-MATNR.
IT_FINAL-MAKTX = IT_MSEG-MAKTX.
IT_FINAL-LMINB = IT_MARD-LMINB.
IT_FINAL-MEINS = IT_MSEG-MEINS.
IT_FINAL-LABST = IT_MARD-LABST.
IT_FINAL-DISPO = IT_MSEG-DISPO.
IT_FINAL-EKGRP = IT_MSEG-EKGRP.
IT_FINAL-LIFNR = IT_MSEG-LIFNR.
IT_FINAL-ISSUE = V_ISSUE.
IT_FINAL-RECEIPT = V_RECEIPT.
IT_FINAL-TOT_LABST = V_LABST.
IT_FINAL-EBELN = IT_MSEG-EBELN.
IT_FINAL-MENGE = IT_MSEG-MENGE1.
IT_FINAL-EINDT = IT_MSEG-EINDT.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " Fetch_DATA
*& Form check_date
text
FORM CHECK_DATE .
DATA: LV_BLDAT LIKE MKPF-BLDAT.
SELECT SINGLE BLDAT
FROM MKPF
INTO LV_BLDAT
WHERE MBLNR = X_MSEG-MBLNR AND
MJAHR = X_MSEG-MJAHR AND
BLDAT IN S_DATE.
IF SY-SUBRC = 0.
MOVE : X_MSEG-MATNR TO IT_MSEG-MATNR,
X_MSEG-WERKS TO IT_MSEG-WERKS,
X_MSEG-LGORT TO IT_MSEG-LGORT,
X_MSEG-MENGE TO IT_MSEG-MENGE,
X_MSEG-MEINS TO IT_MSEG-MEINS,
X_MSEG-LIFNR TO IT_MSEG-LIFNR,
X_MSEG-SHKZG TO IT_MSEG-SHKZG,
X_MSEG-EBELN TO IT_MSEG-EBELN,
X_MSEG-MENGE1 TO IT_MSEG-MENGE1,
X_MSEG-EINDT TO IT_MSEG-EINDT,
X_MSEG-DISPO TO IT_MSEG-DISPO,
X_MSEG-EKGRP TO IT_MSEG-EKGRP,
X_MSEG-MAKTX TO IT_MSEG-MAKTX.
APPEND IT_MSEG.
CLEAR IT_MSEG.
ENDIF.
ENDFORM. " check_date
*& Form PAGE_HEADER
To Print page header and other details
FORM PAGE_HEADER . "#EC CALLED
*---Page header
ULINE AT /1(150).
FORMAT COLOR COL_BACKGROUND INTENSIFIED ON .
WRITE:/ 'Run Date:'(t08), SY-DATUM, 50 'Stanley Works'(t07),
110 'Page No:'(t09), SY-PAGNO LEFT-JUSTIFIED.
WRITE:/ 'Run Time:'(t10), SY-UZEIT, 47 SY-TITLE, 110 SY-UNAME.
WRITE:/ 'Source :'(t11), SY-SYSID, 110 SY-CPROG .
ULINE AT /1(150).
WRITE :/1 'Safety Stock Report for Plant :'(t13),P_WERKS.
ENDFORM. "PAGE_HEADER
*& Form VALIDATE_DATA
Subroutine to Validate selection screen data
FORM VALIDATE_DATA .
DATA V_TEMP(20) TYPE C. "#EC NEEDED
*--Validation for Plant.
CLEAR V_TEMP.
SELECT SINGLE WERKS
INTO V_TEMP
FROM T001W
WHERE WERKS = P_WERKS.
IF SY-SUBRC NE 0.
MESSAGE E001(ZZ) WITH 'Invalid Plant'(t03). "#EC *
ENDIF.
*--Validation for Storage Location.
CLEAR V_TEMP.
IF NOT S_LGORT[] IS INITIAL.
SELECT LGORT INTO V_TEMP UP TO 1 ROWS
FROM T001L
WHERE LGORT IN S_LGORT.
ENDSELECT.
IF SY-SUBRC NE 0.
MESSAGE E001(ZZ) WITH 'Invalid Storage Location'(t04).
ENDIF.
ENDIF.
*--Validation for Material Number.
CLEAR V_TEMP.
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
INTO V_TEMP
UP TO 1 ROWS
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC NE 0.
MESSAGE E001(ZZ) WITH 'Invalid Material Number'(t05).
ENDIF.
ENDIF.
*--Validation for MRP controller.
CLEAR V_TEMP.
IF NOT S_DISPO[] IS INITIAL.
SELECT DISPO INTO V_TEMP UP TO 1 ROWS
FROM T024D
WHERE DISPO IN S_DISPO.
ENDSELECT.
IF SY-SUBRC NE 0.
MESSAGE E001(ZZ) WITH 'Invalid MRP Controller'(t06).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_DATA
*& Form validate_mail
Validate user id
FORM VALIDATE_MAIL .
IF P_MAIL = 'X' AND S_UNAME[] IS INITIAL.
MESSAGE E001(ZZ) WITH 'Enter User Mail id'(t01).
ENDIF.
ENDFORM. " validate_mail
*& Form SEND_MAIL
Send email to SAP inbox
FORM SEND_MAIL .
Structures and internal tables for the send data
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1,
TAB_LINES LIKE SY-TABIX.
Data for the status output after sending
DATA: SENT_TO_ALL LIKE SONV-FLAG.
CLEAR: IT_RECLIST, IT_RECLIST[],
IT_OBJTXT , IT_OBJTXT[],
IT_OBJPACK, IT_OBJPACK[],
IT_OBJBIN , IT_OBJBIN[],X_DOC_CHNG.
LOOP AT IT_HTML.
OBJBIN-LINE = IT_HTML-LINE.
APPEND OBJBIN.
CLEAR OBJBIN.
ENDLOOP.
Create the document which is to be sent
DOC_CHNG-OBJ_NAME = 'List'(012).
DOC_CHNG-OBJ_DESCR = 'Mail'(m05).
Heading
OBJTXT-LINE = 'Safety Stock Report attached'(014).
APPEND OBJTXT.
CLEAR OBJTXT.
Size
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Fill the fields of the packing_list for the main document:
CLEAR OBJPACK-TRANSF_BIN.
The document needs no header (head_num = 0)
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
Body
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'(m02).
APPEND OBJPACK.
Create the attachment (the list itself)
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
Fill the fields of the packing_list for the attachment:
OBJPACK-TRANSF_BIN = 'X'.
Header
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
Body
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'(m01).
OBJPACK-OBJ_NAME = 'Attachment'(m03).
OBJPACK-OBJ_DESCR = 'Mail with pdf Attachment'(018).
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
*-Fill the mail recipient list
LOOP AT S_UNAME.
RECLIST-RECEIVER = S_UNAME-LOW.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
CLEAR: RECLIST.
ENDLOOP.
*-Send the document by calling the SAPoffice API1 module for sending
*-documents with attachments
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = SENT_TO_ALL
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC .
WHEN 0.
MESSAGE s001 WITH 'Mail has been sent successfully'(003).
WHEN OTHERS.
MESSAGE s001 WITH 'Problem in sending the mail'(004).
ENDCASE.
ENDFORM. " SEND_MAIL
*& Form download_display_report
Download and dispaly report
FORM DOWNLOAD_DISPLAY_REPORT .
DATA: X_PARAMS TYPE PRI_PARAMS,
V_VALID.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = ' '
LAYOUT = 'X_65_255'
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = X_PARAMS
VALID = V_VALID.
IF V_VALID <> SPACE.
NEW-PAGE PRINT ON PARAMETERS X_PARAMS NO DIALOG.
PERFORM DISPLAY_REPORT.
NEW-PAGE PRINT OFF.
PERFORM CONV_TO_PDF_DOWNLOAD.
ENDIF.
PERFORM DISPLAY_REPORT.
ENDFORM. " download_display_report
*& Form DISPLAY_REPORT
Display the report
FORM DISPLAY_REPORT .
ULINE AT /0(204).
write:/1 sy-vline no-gap, (10)'Material'(032),
sy-vline no-gap, (40)'Description'(031),
sy-vline no-gap, (15)'Reorder pt'(030),
sy-vline no-gap, (03)'BUn'(029),
sy-vline no-gap, (13)'OnHandQty'(023),
sy-vline no-gap, (13)'OnHandPlnt'(024),
sy-vline no-gap, (13)'YTD issues'(025),
sy-vline no-gap, (13)'YTD Receipts'(026),
sy-vline no-gap, (08)'MRPcntrl'(027),
sy-vline no-gap, (04)'POgrp'(028),
sy-vline no-gap, (13)'POqty'(019),
sy-vline no-gap, (10)'NextDelvDt'(020),
sy-vline no-gap, (10)'Vendor'(021),
sy-vline no-gap, (10)'PO#'(022),
sy-vline no-gap.
ULINE AT /0(204).
loop at it_final.
PERFORM COLOR_SWAP.
write:/1 sy-vline no-gap, (10)it_final-matnr,
sy-vline no-gap, (40)it_final-maktx,
sy-vline no-gap, (15)it_final-lminb, "#EC UOM_IN_MES
sy-vline no-gap, (03)it_final-meins,
sy-vline no-gap, (13)it_final-labst, "#EC UOM_IN_MES
sy-vline no-gap, (13)it_final-tot_labst, "#EC UOM_IN_MES
sy-vline no-gap, (13)it_final-issue, "#EC UOM_IN_MES
sy-vline no-gap, (13)it_final-receipt, "#EC UOM_IN_MES
sy-vline no-gap, (08)it_final-dispo,
sy-vline no-gap, (04)it_final-ekgrp,
sy-vline no-gap, (13)it_final-menge, "#EC UOM_IN_MES
sy-vline no-gap, (10)it_final-eindt,
sy-vline no-gap, (10)it_final-lifnr,
sy-vline no-gap, (10)it_final-ebeln,
sy-vline no-gap.
endloop.
ULINE AT /0(204).
skip 2.
WRITE:/ '******End of Report*******'.
ENDFORM. " DISPLAY_REPORT
*& Form CONV_TO_PDF_DOWNLOAD
Convert to PDF
FORM CONV_TO_PDF_DOWNLOAD .
DATA: V_NUMBYTES TYPE I,
V_SPOOLNO TYPE TSP01-RQIDENT.
CLEAR IT_PDF.
REFRESH IT_PDF.
WAIT UP TO 2 SECONDS.
V_SPOOLNO = SY-SPONO.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = V_SPOOLNO
NO_DIALOG = ' '
IMPORTING
PDF_BYTECOUNT = V_NUMBYTES
TABLES
PDF = IT_PDF.
IF SY-SUBRC = 0. "#EC *
PERFORM PAGE_FORMAT.
ENDIF.
ENDFORM. " CONV_TO_PDF_DOWNLOAD
*& Form page_format
Format the page
FORM PAGE_FORMAT .
DATA : L_LINES TYPE I,
L_TEMP(500) TYPE C,
L_OFFSET TYPE P,
L_LINESLEN(2) TYPE P,
L_MIMELEN(2) TYPE P,
L_TABIX LIKE SY-TABIX.
CLEAR : IT_XI_PDF,
IT_XI_TEMP.
REFRESH : IT_XI_PDF,
IT_XI_TEMP.
IT_XI_PDF[] = IT_PDF[].
Reformat the line to 255 characters wide (code from SAP)
CLEAR: L_TEMP, L_OFFSET, IT_XI_TEMP.
DESCRIBE TABLE IT_XI_PDF LINES L_LINES.
DESCRIBE FIELD IT_XI_PDF LENGTH L_LINESLEN IN CHARACTER MODE.
DESCRIBE FIELD IT_XI_TEMP LENGTH L_MIMELEN IN CHARACTER MODE.
LOOP AT IT_XI_PDF.
L_TABIX = SY-TABIX.
MOVE IT_XI_PDF TO L_TEMP+L_OFFSET.
IF L_TABIX = L_LINES.
L_LINESLEN = STRLEN( IT_XI_PDF ).
ENDIF.
L_OFFSET = L_OFFSET + L_LINESLEN.
IF L_OFFSET GE L_MIMELEN.
CLEAR IT_XI_TEMP.
IT_XI_TEMP = L_TEMP(L_MIMELEN).
APPEND IT_XI_TEMP.
SHIFT L_TEMP BY L_MIMELEN PLACES.
L_OFFSET = L_OFFSET - L_MIMELEN.
ENDIF.
IF L_TABIX = L_LINES.
IF L_OFFSET GT 0.
CLEAR IT_XI_TEMP.
IT_XI_TEMP = L_TEMP(L_OFFSET).
APPEND IT_XI_TEMP.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR : IT_XI_MIME,
IT_XI_MIME[].
LOOP AT IT_XI_TEMP.
IT_XI_MIME(255) = IT_XI_TEMP-LINE.
APPEND IT_XI_MIME.
CLEAR IT_XI_MIME.
ENDLOOP.
Final Data
CLEAR : IT_HTML,
IT_HTML[].
IT_HTML[] = IT_XI_MIME[].
For sending mail
PERFORM SEND_MAIL .
ENDFORM. " page_format
Form : color_swap
Description : Subroutine for color
form color_swap.
if flag is set
if f_color eq 'X'.
clear f_color.
switch off the intensity
format color col_normal intensified off.
else.
if flag is not set.
f_color = 'X'.
switch on the intensity
format color col_normal intensified on.
endif.
endform. " color_swap -
Function Module to convert date to week from Sunday to Saturday
Hi,
In BW the convertion date to week always give week from Monday(1) to Sunday(7)
I'm looking for a function module to convert date to week from Sunday(1) to Saturday(7)
Thanks
SebastienHi,
I think this SAP standardized. Maybe you need to create custom FM.
You can copy SAP FM DATE_GET_WEEK. in the FORM FIRSTWEEK, I see below case,
CASE start_weekday.
WHEN if_calendar_definition=>c_monday.
start_weekday_number = 1.
WHEN if_calendar_definition=>c_tuesday.
start_weekday_number = 2.
WHEN if_calendar_definition=>c_wednesday.
start_weekday_number = 3.
WHEN if_calendar_definition=>c_thursday.
start_weekday_number = 4.
WHEN if_calendar_definition=>c_friday.
start_weekday_number = 5.
WHEN if_calendar_definition=>c_saturday.
start_weekday_number = 6.
WHEN if_calendar_definition=>c_sunday.
start_weekday_number = 7.
ENDCASE.
Maybe you can play something here. -
Word in proper case ( First letter Capiral and remaining small case )
Hi all
I wanted to make a sentence as a proper case one. like All first letter of the word should be in capital and remaining in small Letter..
For example..
I have a sentence in Lower case ..
'rupees twi thousand only'.
i wanted to make it as follows..
Rupees Two Thousand Only...
Cheers
ChristinaHere is an alternative approach which uses a regular expression and runs over 10 times faster than calling STRING_UPPER_LOWER_CASE:
form proper_case changing p_name.
data:
li_ofs type i.
translate p_name to lower case.
while sy-subrc = 0.
translate p_name+li_ofs(1) to upper case.
find regex '\b[a-z]' in p_name match offset li_ofs.
endwhile.
endform. -
How to convert date ="23-08-13" to date="23-AUG-13"?
Hi,
Need help!!!
I wanna convert date='23-08-13' to date='23-AUG-13'.
How can i do it????
Please help as soon as passibleYour date string is a character format one, can not be accepted as a date. Hence,I would like to request you to change your datatype as DATETIME. As satheesh suggested, you can do the formatting at application side.
But for any case, you want to do it at SQL Server, the below is another option.(assuming the month follows the same format 0 will be prefixed for 1-9 digits)
Declare @chardate varchar(8)='23-08-13'
Select LEFT(@chardate,3)+Case
When charindex('-01-',@chardate,0) <> 0 Then 'Jan'
When charindex('-02-',@chardate,0) <> 0 Then 'Feb'
When charindex('-03-',@chardate,0) <> 0 Then 'Mar'
When charindex('-04-',@chardate,0) <> 0 Then 'Apr'
When charindex('-05-',@chardate,0) <> 0 Then 'May'
When charindex('-06-',@chardate,0) <> 0 Then 'Jun'
When charindex('-07-',@chardate,0) <> 0 Then 'Jul'
When charindex('-08-',@chardate,0) <> 0 Then 'Aug'
When charindex('-09-',@chardate,0) <> 0 Then 'Sep'
When charindex('-10-',@chardate,0) <> 0 Then 'Oct'
When charindex('-11-',@chardate,0) <> 0 Then 'Nov'
When charindex('-12-',@chardate,0) <> 0 Then 'Dec'
else '' end +RIGHT(@chardate,3) -
Hi,
Am loading from a flat file. I need to convert all the data into upper case before loading.
Can some one help me out with this. Where and how?
Thanks.you'll have to do that for each single object; depending on how many fields you have you may change your flat file or do that during start routine.
LOOP AT DATA_PACKAGE.
TRANSLATE DATA_PACKAGE-FIELD1 TO UPPER CASE.
TRANSLATE DATA_PACKAGE-FIELDN TO UPPER CASE.
MODIFY DATA_PACKAGE.
ENDLOOP.
hope this helps...
Olivier. -
Hello,
I have two questions relating to a part of a source code, which I have to analyze:
CONVERT DATE INTAB-DATUM INTO INVERTED-DATE DAT_INV.
SELECT SINGLE * FROM TCURR WHERE KURST = INTAB-KURST AND
FCURR = INTAB-WAEKZ AND
TCURR = EUR AND
GDATU = DAT_INV.
I don`t know the command CONVERT DATE INTAB-DATUM INTO INVERTED-DATE DAT_INV. For what purpose do I need this command?
Another question is the SELECT-command. I always thought, that it is necessary to specify a workarea where the result of the Select-Command will be saved. Is that wrong?
Thanks for your help.
Regards,
TobiasHi, here is the explanation for your two queries:
1. You can actually go for F1 help for this and get some idea...
In some cases (for example, when sorting dates in descending order), it is useful to convert a date from format D to an inverted date by using the keyword CONVERT.
EX: DATA: odate TYPE d VALUE '19955011',
idate LIKE odate.
DATA field(8).
field = odate.
WRITE / field.
CONVERT DATE odate INTO INVERTED-DATE idate.
field = idate.
WRITE / field.
CONVERT INVERTED-DATE idate INTO DATE odate.
field = odate.
WRITE / field.
Output:
19955011
80044988
19955011
2. If you mention a table under TABLES declaration, then it means that a workarea with the same table name has been created and hence when u don't specify INTO TABLE, it won't give any error. But if u don't specify the tablename under TABLES it will show error..
If you check in your program the table might have been declared under TABLES..
Hope this helps..
Maybe you are looking for
-
Mac OS X - Problem with FireWire Hard Drive Recognition
Hoping for some help: My computer is misrecognizing one of the partitions on my FireWire external hard drive (LaCie Porsche 250GB). Two partitions appear correctly on the desktop but the one I have reserved for Time Machine is showing as a 1G iPod. I
-
Business partner not created in SRM in HR-SRM integration
Hi All, We are setting up SRM HR integration set up with ALE idocs message type. I ve done configuration as per guide available in SAP.Setting up parnter profiles,maintaining message types in both the systems ,mainyaining entries in tavle T77S0 for H
-
Problem with german date and rfc function
Hello, i have created a function with the following import parameter in our ERP System: DATUM_BIS TYPE DATUM DATUM_VON TYPE DATUM SYSTEM TYPE CHAR4 If i use this function as data service in the vc and create an
-
hi in import process -i done PO,MIRO and then condtion values not coming J1IEX fields BED,AED,SED please help
-
How can I put a list of ten email addresses into one contact file?
I have a lst of ten + people that I want to put into my address book under one disignated. Whjat is the easier way to accomplish that task? I do not see anything in the Menu bar that addresses this. Thanks. Doug Wise