Wednesday, January 11, 2012

WebDynPro how to read value from a table with button.

Recent task was given by Chin Yc. which to add a button to on of the column in all the rows.
Which supposed to show notes.
How does the button proceed to read from the table? below are the sample coding
"get exercise informations
DATA lo_nd_ess_profile TYPE REF TO if_wd_context_node. "READING NODES
DATA lo_el_ess_profile TYPE REF TO if_wd_context_element"READING NODES
DATA ls_ess_profile TYPE wd_this->Element_ess_profile."READING NODES
"The nodes referred named ess_profile
" Set Lead Selection on user selected row
" (the row where user clicked the Exercise button on)
"Getting the current node valuelo_nd_ess_profile = wd_context->get_child_node( name = wd_this->wdctx_ess_profile ).
lo_el_ess_profile = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
lo_nd_ess_profile->set_lead_selection( element = lo_el_ess_profile ).
lo_el_ess_profile->get_static_attributes(
IMPORTING
static_attributes = ls_ess_profile ).
DATA: whatevervalue type char255, whatevervalue1 type char255.
whatevervalue = ls_ess_profile-endda.
whatevervalue2 = ls_ess_profile-begda


Tuesday, December 20, 2011

Note: Changing payslip in portal

source : http://forums.sdn.sap.com/thread.jspa?threadID=1909760&tstart=15#10075902
You need to make a new form using smartforms and put it in EDPDF .

1. HRFOR - This feature decides whether to use HRFORMS or CEDT forms
(configured in PE51) for the payslip. If HRFORMS, the name of HRFORM has
to be mentioned here. If PE51 needs to be used then $CEDT$ should be
specified.

2. EDTIN - This should hold the value of the variant to be executed in
the CEDT program (payslip program). The variant should be proper with
the with the correct CEDT (payslip) form name and other parameters.

3. EDPDF - The name of the smartform (standard smartform
HR_ESS_PAYSLIP_TO_PDF or customer specific form) used to show the output
in the ESS.

Abap Creating a workable button on the selection screen

*&---------------------------------------------------------------------*
*& Report Y_MARK_TEST_BUTTON
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Y_MARK_TEST_BUTTON.
TABLES sscrfields.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.


PARAMETERS : P_FILE LIKE RLGRAP-FILENAME default 'C:\EMAIL_RESULT.XLS'.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (20) dl_excel USER-COMMAND dl_excel. "button!
SELECTION-SCREEN END OF LINE.


SELECTION-SCREEN END OF BLOCK B1.


* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'EMAIL_RESULT'
initial_directory = 'C:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.


AT SELECTION-SCREEN OUTPUT.
MOVE 'Download' TO dl_excel. "giving the button label

AT SELECTION-SCREEN.
case sy-ucomm.
when 'DL_EXCEL'.
"DO WHAT EVER YOU LIKE
endcase.

abap : How to save a file using a dialog box

*Selecting a file to save too, plus inserting default file extension .xls
tables rlgrap.

DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.

selection-screen begin of block m with frame.
PARAMETERS: p_file TYPE rlgrap-filename.
selection-screen end of block m.

* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'accountsdata'
initial_directory = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.


source :
http://www.sapdev.co.uk/file/file_objsave.htm

Abap how to read a comma delimited data into internal table


COMMA DELIMITED file to INTERNAL TABLE


don't know about gui_upload, the way we do it is:

declare an internal table like:
data: begin of i_rec occurs 0,
filler(200),
end of i_rec.
data: begin of itab occurs 0,
field1,
field2,
...
end of itab.
Itab is the table you want to fill, i_rec is just a temporary intermediary table.

data: sep_field(1) value ','.
that's your separator (comma or something else).

First call the function GUI_UPLOAD and fill table i_rec with the data in your file.
then:

loop at i_rec.
split i_rec-filler at sep_field into itab-field1 itab-field2 ...
append itab.
clear itab.
endloop.

this should do the trick for as far as I know.


good luck,

ioana

source
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/comma-delimited-file-to-internal-table-151418

Monday, December 19, 2011

Abap how to create an excel file sample

REPORT ZEX_DATATOEXCEL .

Parameters: P_file like RLGRAP-FILENAME.

data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.

data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.


int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.

int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.

int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.

int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.

int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.


CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ' '
* PIVOT_SHEET_NAME = ' '
* PASSWORD = ' '
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


source
http://abaplovers.blogspot.com/2008/05/abap-internal-table-to-excel-sheet.html

How to debug universal worklist, approval pending list, approval program.

Knowledge sharing by Mohd Khairil Bin Markom my colleague :)

Recent workflow debugging for supervisor
How do we debug a program which has been configured in swfvisu?

Applicant we can easily debugged from the
Transaction code = SE80

But as the work flow comes into the picture the data/application is routed to the supervisor

STEP 1
Still using the transaction code SE80.

Put a debugmode under
- Component Controller -> Method -> wdoinit (place any break point there tips: best at the first line)
- Test run first! Let it stay in the debug mode and then proceed to STEP 2

STEP 2
Log into the portal
1.CLICK on the work ( universal worklist - the place where you can see the approval's pending list)
2.CLICK on the document that is pending

STEP 3
Once step 1 and step 2 is achieved.
You can start you exploration to debug which ever error you can find in the approval webdynpro

Monday, December 12, 2011

Sample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY

Sample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY

By Vikram Chellappa, Mouri Tech Solutions

*&---------------------------------------------------------------------* *& Report  ZALV_REPORT_SFLIGHT *& *&---------------------------------------------------------------------* * Published at SAPTechnical.COM *&---------------------------------------------------------------------*
REPORT  ZALV_REPORT_SFLIGHT. TABLES : SFLIGHT. TYPE-POOLS : SLIS.
**INTERNAL TABLE DECLARTION DATA : WA_SFLIGHT TYPE SFLIGHT,        IT_SFLIGHT TYPE TABLE OF SFLIGHT.
**DATA DECLARTION DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,       GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,       GD_REPID     LIKE SY-REPID,       G_SAVE TYPE C VALUE 'X',       G_VARIANT TYPE DISVARIANT,       GX_VARIANT TYPE DISVARIANT,       G_EXIT TYPE C,       ISPFLI TYPE TABLE OF SPFLI.
* To understand the importance of the following parameter, click here. **SELECTION SCREEN DETAILS SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002 . PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT. SELECTION-SCREEN END OF BLOCK B1. **GETTING DEFAULT VARIANT INITIALIZATION.   GX_VARIANT-REPORT = SY-REPID.   CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'     EXPORTING       I_SAVE     = G_SAVE     CHANGING       CS_VARIANT = GX_VARIANT     EXCEPTIONS       NOT_FOUND  = 2.   IF SY-SUBRC = 0.     VARIANT = GX_VARIANT-VARIANT.   ENDIF.
**PERFORM DECLARATIONS START-OF-SELECTION.   PERFORM DATA_RETRIVEL.   PERFORM BUILD_FIELDCATALOG.   PERFORM DISPLAY_ALV_REPORT. 
*&---------------------------------------------------------------------* *&      Form  BUILD_FIELDCATALOG *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM BUILD_FIELDCATALOG .
  FIELDCATALOG-FIELDNAME   = 'CARRID'.   FIELDCATALOG-SELTEXT_M   = 'Airline Code'.   FIELDCATALOG-COL_POS     = 0.   APPEND FIELDCATALOG TO FIELDCATALOG.   CLEAR  FIELDCATALOG. 
  FIELDCATALOG-FIELDNAME   = 'CONNID'.   FIELDCATALOG-SELTEXT_M   = 'Flight Connection Number'.   FIELDCATALOG-COL_POS     = 1.   APPEND FIELDCATALOG TO FIELDCATALOG.   CLEAR  FIELDCATALOG.
  FIELDCATALOG-FIELDNAME   = 'FLDATE'.   FIELDCATALOG-SELTEXT_M   = 'Flight date'.   FIELDCATALOG-COL_POS     = 2.   APPEND FIELDCATALOG TO FIELDCATALOG.   CLEAR  FIELDCATALOG.
  FIELDCATALOG-FIELDNAME   = 'PRICE'.   FIELDCATALOG-SELTEXT_M   = 'Airfare'.   FIELDCATALOG-COL_POS     = 3.   FIELDCATALOG-OUTPUTLEN   = 20.   APPEND FIELDCATALOG TO FIELDCATALOG.   CLEAR  FIELDCATALOG. ENDFORM.                    " BUILD_FIELDCATALOG   *&---------------------------------------------------------------------* *&      Form  DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM DISPLAY_ALV_REPORT .   GD_REPID = SY-REPID.   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'     EXPORTING       I_CALLBACK_PROGRAM      = GD_REPID       I_CALLBACK_TOP_OF_PAGE  = 'TOP-OF-PAGE'  "see FORM       I_CALLBACK_USER_COMMAND = 'USER_COMMAND'       IT_FIELDCAT             = FIELDCATALOG[]       I_SAVE                  = 'X'       IS_VARIANT              = G_VARIANT     TABLES       T_OUTTAB                = IT_SFLIGHT     EXCEPTIONS       PROGRAM_ERROR           = 1       OTHERS                  = 2.   IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.   ENDIF. ENDFORM.                    "DISPLAY_ALV_REPORT
" DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* *&      Form  DATA_RETRIVEL *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM DATA_RETRIVEL .   SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT. ENDFORM.                    " DATA_RETRIVEL
*-------------------------------------------------------------------* * Form  TOP-OF-PAGE                                                 * *-------------------------------------------------------------------* * ALV Report Header                                                 * *-------------------------------------------------------------------* FORM TOP-OF-PAGE. *ALV Header declarations   DATA: T_HEADER TYPE SLIS_T_LISTHEADER,         WA_HEADER TYPE SLIS_LISTHEADER,         T_LINE LIKE WA_HEADER-INFO,         LD_LINES TYPE I,         LD_LINESC(10) TYPE C.
* Title   WA_HEADER-TYP  = 'H'.   WA_HEADER-INFO = 'SFLIGHT Table Report'.   APPEND WA_HEADER TO T_HEADER.   CLEAR WA_HEADER.
* Date   WA_HEADER-TYP  = 'S'.   WA_HEADER-KEY = 'Date: '.   CONCATENATE  SY-DATUM+6(2) '.'                SY-DATUM+4(2) '.'                SY-DATUM(4) INTO WA_HEADER-INFO.   "todays date   APPEND WA_HEADER TO T_HEADER.   CLEAR: WA_HEADER. 
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'     EXPORTING       IT_LIST_COMMENTARY = T_HEADER. ENDFORM.                    "top-of-page

SOURCE
http://www.saptechnical.com/Tutorials/ALV/SampleALVGridProgram.htm

Abap: Country Grouping

DATA P_MOLGA TYPE MOLGA.

CALL FUNCTION 'HR_COUNTRYGROUPING_GET'
EXPORTING
PERNR = WD_COMP_CONTROLLER->PERNR
* TCLAS = 'A'
* BEGDA = '18000101'
* ENDDA = '99991231'
* WERKS =
IMPORTING
MOLGA = P_MOLGA
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2

IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


source

Tuesday, November 15, 2011

SAP script

OPEN_FORM - Open SAPscript form printing
- to only preview the form: options-tdpreview='X' (options-tdnoprint forbids print even from preview)
- to get OTF data instead of printing: options-tdgetotf='X'
- to output OTF data to memory buffer instead of printing: device='OTF_MEM'

Code:

REPORT z_sapscript_form.
data: w_options type itcpo,
w_result type itcpp,
w_otf like itcoo occurs 0 with header line,
w_ascii like tline occurs 0 with header line,
w_device(40) type c,
w_num like sy-tabix.

parameters: printer like tsp03-padest lower case default 'locl',
layoutst like rsscf-tdform default 'MEDRUCK'.
selection-screen: begin of line.
parameters p_prn radiobutton group rad0.
selection-screen: comment 4(60) cmt_prn for field p_prn,
end of line.
selection-screen: begin of line.
parameters p_pre radiobutton group rad0.
selection-screen: comment 4(60) cmt_pre for field p_pre,
end of line.
selection-screen: begin of line.
parameters p_mem radiobutton group rad0.
selection-screen: comment 4(60) cmt_mem for field p_mem,
end of line.
selection-screen: begin of line.
parameters p_otf radiobutton group rad0.
selection-screen: comment 4(60) cmt_otf for field p_otf,
end of line.

initialization.
cmt_prn = 'Print to spool'.
cmt_pre = 'Only create form and preview, no print'.
cmt_mem = 'Output OTF to memory buffer and convert to ASCII'.
cmt_otf = 'Only get OTF data'.

start-of-selection.
perform: form_open,
print_item,
form_close.
case 'X'.
when p_prn. write: / 'See Spool#', w_result-tdspoolid,
'(', w_result-tdpages, ' pages )'.
when p_pre.
when p_otf. loop at w_otf.
write / w_otf.
endloop.
when p_mem. perform get_ascii.
endcase.
*---------------------------------------------------------------------*
* FORM FORM_OPEN *
*---------------------------------------------------------------------*
* Start of printing the form *
*---------------------------------------------------------------------*
form form_open.
w_options-tddest = printer.
w_device = 'PRINTER'. "default
case 'X'.
when p_pre. w_options-tdpreview = 'X'.
w_options-tdnoprint = 'X'.
when p_prn.
when p_mem. w_device = 'OTF_MEM'.
when others. w_options-tdgetotf = 'X'.
endcase.
call function 'OPEN_FORM'
exporting
device = w_device
dialog = ' '
form = layoutst
options = w_options
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
others = 11.
write: / 'Form open. Return code =', sy-subrc.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform.
*&---------------------------------------------------------------------*
*& Form PRINT_ITEM
*&---------------------------------------------------------------------*
* Print form item *
*----------------------------------------------------------------------*
form print_item.
call function 'WRITE_FORM'
exceptions
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
bad_pageformat_for_print = 7
spool_error = 8
others = 9.
write: / 'Form print. Return code =', sy-subrc.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " PRINT_ITEM
*---------------------------------------------------------------------*
* FORM FORM_CLOSE *
*---------------------------------------------------------------------*
* End of printing the form *
*---------------------------------------------------------------------*
form form_close.
call function 'CLOSE_FORM'
importing
result = w_result
tables
otfdata = w_otf
exceptions
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
others = 5.
write: / 'Form close. Return code =', sy-subrc,
'Spool#', w_result-tdspoolid.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
describe table w_otf lines w_num.
write: / 'OTF has', w_num, 'lines.'.
endif.
endform.
*&---------------------------------------------------------------------*
*& Form get_ascii
*&---------------------------------------------------------------------*
* convert OTF from memory to ASCII text
*----------------------------------------------------------------------*
form get_ascii.
call function 'CONVERT_OTF_MEMORY'
tables
lines = w_ascii
exceptions
memory_empty = 1
err_max_linewidth = 2
err_format = 3
err_conv_not_possible = 4
others = 5.
write: / 'Convert OTF memory. Return code =', sy-subrc.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
describe table w_ascii lines w_num.
write: / 'OTF has', w_num, 'lines.'.
loop at w_ascii.
write: / w_ascii.
endloop.
endif.
endform. " get_ascii


CLOSE_FORM - End SAPscript layout set printing
- spool #: result-tdspoolid
- OTF data: otfdata (when options-tdgetotf='X' in OPEN_FORM)

WRITE_FORM - Output SAPscript text element in form window

CONTROL_FORM - Control SAPscript form output
- issue command to the form, e.g. exporting command = 'NEW-PAGE'

CONVERT_OTF_MEMORY - Convert SAPscript OTF from memory into text format
output: table of structure TLINE (OTF saved to memory buffer by OPEN_FORM)

SAVE_OTF_TO_MEMORY - Write OTF format to memory
export|import OTF internal table to|from memory id ...

READ_OTF_FROM_MEMORY - Read OTF from memory

PRINT_OTF - print OTF from internal table

DISPLAY_OTF - Display an OTF table on the screen

DISPLAY_POSTSCRIPT - Display a postscript table on the screen tables postscript structure itcps

CONVERT_OTF - Convert OTF format to various formats (TLINE table) ASCII or PDF
Code:
CALL FUNCTION "CONVERT_OTF"
EXPORTING FORMAT = "PDF"
IMPORTING BIN_FILESIZE = FILE_LEN
TABLES OTF = OTFDATA
LINES = PDFDATA
EXCEPTIONS ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.


CONVERT_OTF_2_PDF - Convert OTF to PDF (TLINE table).
OTF can be filled used archivelink. Calls CONVERT_OTF.

CONVERT_OTF_2_PDF_ARCHIVELINK - Convert OTF to PDF (TLINE table).
Calls CONVERT_OTF. Looks like the function names for these two functions are mixed up J

CONVERT_OTF_AND_FAX

CONVERT_OTF_AND_MAIL

CONVERT_OTFSPOOLJOB_2_PDF
Input: spool # (SAPscript: tsp01-rqdoctype='OTF'); Output: PDF as internal table (TLINE)

CONVERT_ABAPSPOOLJOB_2_PDF
Input: spool # (ABAP listing: tsp01-rqdoctype='LIST'); Output: PDF as internal table (TLINE)

OTF_CONVERT - wraps several other function modules. Will convert OTF to ASCII or PDF

SX_OBJECT_CONVERT_OTF_PDF - Conversion From OTF to PDF (SAPScript conversion)

SX_OBJECT_CONVERT_OTF_PRT - Conversion From OTF to Printer Format (SAPScript conversion)

SX_OBJECT_CONVERT_OTF_RAW - Conversion From OTF to ASCII (SAPScript conversion)

Monday, November 14, 2011

To assign enter button as execute in selection screen

SELECTION-SCREEN: BEGIN OF LINE,
COMMENT 1(31) TEXT-002 FOR FIELD IN_YEAR MODIF ID A.
PARAMETERS: IN_YEAR(4) MODIF ID A. " a field
SELECTION-SCREEN PUSHBUTTON (20) execut USER-COMMAND execut MODIF ID A. "button!
SELECTION-SCREEN END OF LINE.
===========================================
AT SELECTION-SCREEN OUTPUT.
MOVE 'Execute' TO execut. "giving the button label
..
...
....
===========================================
AT SELECTION-SCREEN.

if sscrfields-ucomm eq 'EXECUT'.
sscrfields-ucomm = 'ONLI'. " this is the execute value passed!
endif.

..
...
....

HR_GET_EMPLOYEES_FROM_USER

"mark---------------------
DATA : ee_tab TYPE PERNR_US_TAB,
wa_ee_tab type line of PERNR_US_TAB.
* get pernr, molga, ename
CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'
EXPORTING
user = sy-uname
TABLES
ee_tab = ee_tab.
LOOP AT ee_tab into wa_ee_tab.
ENDLOOP.

PNPPERNR-SIGN = 'I'.
PNPPERNR-OPTION = 'EQ'.
PNPPERNR-LOW = wa_ee_tab-pernr.
APPEND PNPPERNR.

How to use a table with no header

DATA : ee_tab TYPE PERNR_US_TAB,
wa_ee_tab type line of PERNR_US_TAB.
* get pernr, molga, ename
CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'
EXPORTING
user = sy-uname
TABLES
ee_tab = ee_tab.

LOOP AT ee_tab into wa_ee_tab.

ENDLOOP.

Sunday, November 13, 2011

How to hide certain fields or button in your selection screen

*&---------------------------------------------------------------------*
*& Report Y_MARK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Y_MARK.


DATA: D_UCOMM LIKE SY-UCOMM.

PARAMETERS: P_GRPA1(10) MODIF ID A,
P_GRPA2(5) MODIF ID A,
P_GRPB1(2) MODIF ID B.

PARAMETERS: P_ACTA RADIOBUTTON GROUP RAD1 USER-COMMAND ACT DEFAULT 'X',
P_ACTB RADIOBUTTON GROUP RAD1.

AT SELECTION-SCREEN.
D_UCOMM = SY-UCOMM.

AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF P_ACTA = 'X'.
IF SCREEN-GROUP1 = 'B'.
SCREEN-ACTIVE = 0.
ENDIF.
ELSEIF P_ACTB = 'X'.
IF SCREEN-GROUP1 = 'A'.
SCREEN-ACTIVE = 0.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.

START-OF-SELECTION.

Tuesday, November 8, 2011

The maintenance dialog for zXXXXX is incomplete or not defined

This is how you create maintenance dialog for ztable.

Use tcode SE11, enter the table name click change. In the next screen, click Utitlies-->table maintenance generator.

Enter &NC& as the auth group.
Enter the function group to use (ex. Z_TABMAINT)

click One Step, enter '1' as the screen number. Click the create button.

Once generated, you can use it by going to SM30, enter table name and click maintain.

Source
http://forums.sdn.sap.com/thread.jspa?threadID=1087759

IAC - how to create

IAC iview is used when you want to create an iview of an ITS service. In the thrid step of creating IAC iview we should pass the ITS service name for IAC property.
Steps to create IAC iview.
1. Create a system object for R/3 with ITS property category also.
2. create a Service in transaction using SICF. The below thread will help you.

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2204
3. create an an iview and give the service name in IAC textbox not R/3 System name.

Also check:
https://www.sdn.sap.com/irj/sdn/thread?threadID=243082

http://help.sap.com/saphelp_nw04/helpdata/en/44/216fe21784648ee10000000a1553f7/frameset.htm

M again mentioning all the steps for IAC iview creation, plz check.

Steps to display the SAP Transaction as Internet Application Component (IAC) in Portal
The following three tasks have to be performed step by step:
1.Creating the IAC
2.Activating the IAC
3.Creating an IAC iview in the portal

Creating an IAC
1)Go to transaction sicf. Click on the "watch"button. Under Virtual Host / Services expand Default_host > SAP > bc > gui > sap > ITS. Now right click over ITS and select New Sub-Element.
2)In the new dialog box give the name of the service.
3)Now write a description in the description box. In the drop box corresponding to GUI Link select the option Yes. Now click the GUI Transaction button and enter the parameters as shown below.
Parameter Name Value
~TRANSACTION sm36
~THEME 99
~generateDynpro 1
~noHeaderOkCode 1
4)Now go to the tab Handler List and maintain the parameter CL_HTTP_EXT_ITS.
Now click on the save button from the top and save it.
You can now see the service under ITS.

Activating the service

After saving the IAC, we need to activate the service. Select the service under ITS, right click over it and select Activate Service. The service will get activated.

Creating an IAC iview in the portal

We need to create an iview which in tern will use a system to connect to the ITS.
In the WAS property of the system maintain the following property
Web As Host Name :
Web As Path /sap/bc/gui/sap/its/
Web As Protocol HTTP/HTTPS
Under Content Administration > Portal Content create an iview of type SAP IAC iview and specify the system alias name and the IAC.

source
http://forums.sdn.sap.com/thread.jspa?threadID=841234

Monday, November 7, 2011

HR reporting - defaulting value through programming

Ever wanted to put a default value into the HR reporting....

Now you can.

1. Run the program and press F1 to the defaulted field you want to initialise.

2. Under the abap coding "INITIALIZATION" copy the code below please modify base on your field name.

INITIALIZATION. "TO ADD IF THERE IS ANY TO INITIALIZE
PNPSTAT2-SIGN = 'I'.
PNPSTAT2-OPTION = 'EQ'.
PNPSTAT2-LOW = '0'. PNPSTAT2-HIGH = '0'. APPEND PNPSTAT2.

3. Activate and run the program! Walla Done...

Tuesday, November 1, 2011

SAP Remove Comma / Remove full stop




**********************************************************************

* FORM    :   remove_comma

* Created :  13.09.2011 18:33:22

**********************************************************************

FORM REMOVE_COMMA CHANGING $FIELD.



  DATA : WA_INDEX(02) TYPE I.

  DATA : F3(10) TYPE C.



  F3 = $FIELD.



  DO 10 TIMES.

    IF F3+WA_INDEX(01) EQ ','.

      F3+WA_INDEX(01) = ''.

    ENDIF.

    ADD TO WA_INDEX.

  ENDDO.



  CONDENSE F3 NO-GAPS.

  $FIELD = F3.



ENDFORM. " remove_comma



**********************************************************************


* FORM    :   remove_fullstop

* Created :  13.09.2011 18:33:22

**********************************************************************

FORM REMOVE_FULLSTOP CHANGING $FIELD.



  DATA : WA_INDEX(02) TYPE I.

  DATA : F3(10) TYPE C.



  F3 = $FIELD.



  DO 10 TIMES.

    IF F3+WA_INDEX(01) EQ '.'.

      F3+WA_INDEX(01) = ''.

    ENDIF.

    ADD TO WA_INDEX.

  ENDDO.



  CONDENSE F3 NO-GAPS.

  $FIELD = F3.



ENDFORM. " remove_fullstop


Thursday, October 13, 2011

Screen programming

Screen programming

DIAGRAM 1.0

DIAGRAM 2.0

Best practice to make the sy-ucomm to be fcode.

 

leave to screen 0. <--- to exit the current screen
leave program. <---- to exit the whole rogram

*** normally the program created in module pool (not executable) execute via TRANSACTION CODE



PROGRAM  ZBC400_22_SCREEN.

DATA : FCODE TYPE SY-UCOMM.
tables : sflight.

*&---------------------------------------------------------------------*
*&      Module  SET_GUI_AND_TITLE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE SET_GUI_AND_TITLE OUTPUT.
  set PF-STATUS 'GUI100'.
  set TITLEBAR  'TITLE' with sy-uname.
ENDMODULE.                 " SET_GUI_AND_TITLE  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PROCESS_F_CODE  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE PROCESS_F_CODE INPUT.
CASE FCODE.
  when 'ENTER'.

    select single *
      from sflight
      WHERE carrid = sflight-carrid
      and   connid = sflight-connid
      and   fldate = sflight-fldate.

    call screen 200.

  WHEN 'GO_BACK'.

    IF sy-dynnr = 200.
        LEAVE to SCREEN 0.
      else.
        leave PROGRAM.
    ENDIF.

  WHEN 'SPECIAL'.
    MESSAGE i010(ad) with 'special report'.
  WHEN OTHERS.
ENDCASE.

ENDMODULE.                 " PROCESS_F_CODE  INPUT

 

DIAGRAM 3.0

Based on the above data.

 

1. create a program (module pool)

2. create screen100 *try not to use 1000 above cause it is standard

PROCESS BEFORE OUTPUT.
 MODULE set_gui_and_title.
* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.

-- remember to use the Fcode in element list

3. create gui_status <--- this is for the screen

DIAGRAM 4.0

with this you can create icon and remember th fcode you can use the variable you created too

As for the application tool bar you can add your own ICON!! and apply the same FCODE too

 

Last but not least dont forget to create the title 

DIAGRAM 5.0

**** CLICK on SCREEN then LAYOUT

here you can create your layout 

remember for function aka push button remember to put the function code so that your system can manipulate it

remember what ever RED in colour when editing during layout its meaning is more towards error.

REMEMBER TO CALL YOUR PBO AND PAI  MODULE INSIDE THE SCREEN!!! EXAMPLE DIAGRAM 3.0

 

* notice that we are all working in se80 that is why you can see the layout besides 

* remember the coding above is sufficient for normal usage.

SAP sample coding of a almost complete understanding of the screen

*&---------------------------------------------------------------------*
*& Report ZDC_SALES_REP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDC_SALES_REP no standard page heading
line-size 132
line-count 65(3).

data:
line_no(5) type n.

data:
v_matnr type vbap-matnr.


data:
it_salesdet type table of zdc_sales_doc,
wa_salesdet like line of it_salesdet.


* selection screen
parameters:
p_vkorg type vbak-vkorg obligatory.

select-options:
s_matnr for v_matnr.

parameters:
p_flag as checkbox.


initialization.
p_vkorg = 1000.

s_matnr-sign = 'I'.
s_matnr-option = 'BT'.
s_matnr-low = 'M-01'.
s_matnr-high = 'M-03'.
append s_matnr.

clear s_matnr.
s_matnr-sign = 'E'.
s_matnr-option = 'EQ'.
s_matnr-low = 'M-02'.
append s_matnr.


at selection-screen.
if p_flag = 'X' and s_matnr[] is not initial.
message e010(ad) with 'Error'.
endif.



start-of-selection.

" get data
select * into table it_salesdet
from zdc_sales_doc
where vkorg = p_vkorg
and matnr in s_matnr.

" display report
loop at it_salesdet into wa_salesdet.
add 1 to line_no.
write: / line_no,
wa_salesdet-vbeln color col_key,
wa_salesdet-posnr color col_key,
wa_salesdet-kunnr color col_positive,
wa_salesdet-netwr,
wa_salesdet-matnr,
wa_salesdet-ZMEng color col_total.
endloop.



end-of-selection.



top-of-page.
write: /80 'Page:', sy-pagno.
uline.
clear line_no.

end-of-page.
format color col_total.
write: /(132) '--Continued--' centered.