Tuesday, November 8, 2011

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.

Wednesday, October 12, 2011

DATA DECLARATION SAP

*&---------------------------------------------------------------------*
*& Report ZBC400_22_ITAB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZBC400_22_ITAB.
"BEST PRACTICE TO DECLARE TYPE FIRST
"THEN ONLY ASSIGN THE TYPE TO EITHER STRUCTURE OR TABLE

"TYPE TABLE OF <<<< KEY WORD TO CREATE AN INTERNAL TABLE
"THEN FOLLOWED BY
"LIKE LINE OF <<<< KEY WORD TO CREATE A WORK AREA / STRUCTURE FOR THE TABLE

*defination of internal table
*TYPES : TY_FLIGHT TYPE SFLIGHT.
TYPES :
BEGIN OF TY_FLIGHT. "this is to include a table structure
INCLUDE STRUCTURE SFLIGHT. "this is to include a table structure
TYPES : "this extra type is due to the table being inserted
F1 TYPE C LENGTH 4,
F2 TYPE C LENGTH 4,
F3 TYPE SFLIGHT-FLDATE,
END OF TY_FLIGHT.

DATA: IT_FLIGHT TYPE TABLE OF TY_FLIGHT, "[[[ THIS IS THE INTERNAL TABLE BEING CREATED ]]]
WA_FLIGHT LIKE LINE OF IT_FLIGHT. " WA_FLIGHT TYPE TY_FLIGHT
"< DONT FOLLOW THE COMMENT THOUGH SAME
START-OF-SELECTION.
SELECT * INTO TABLE IT_FLIGHT FROM SFLIGHT. "MODIFY
LOOP AT IT_FLIGHT INTO WA_FLIGHT. "MODIFY
WA_FLIGHT-PRICE = '88.88'. "CHANGING TO STRUCTURE ONLY "MODIFY
MODIFY IT_FLIGHT INDEX SY-TABIX FROM WA_FLIGHT. "MODIFY
"MODIFY
ENDLOOP.
DELETE IT_FLIGHT WHERE CARRID = 'LH'. "DELETE
"APPEND WORKS ONLY FOR STANDARD DATA
CLEAR WA_FLIGHT. "APPEND
WA_FLIGHT-CARRID = 'LH'. "APPEND
WA_FLIGHT-CONNID = '8888'. "APPEND
WA_FLIGHT-FLDATE = '20111231'. "APPEND
APPEND WA_FLIGHT TO IT_FLIGHT. "APPEND

CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
READ TABLE IT_FLIGHT INTO WA_FLIGHT WITH KEY CARRID = 'JL'. "READ AND ASSIGN TO WA_FLIGHT

IF SY-SUBRC = 0 . "DISPLAYED ASSIGNED WA_FLIGHT
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF. "DISPLAYED ASSIGNED WA_FLIGHT


CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
SORT IT_FLIGHT BY CARRID. "SORT IT_FLIGHT BY CARRID
LOOP AT IT_FLIGHT INTO WA_FLIGHT FROM SY-TABIX. "LOOP AND ASSIGN TO WA_FLIGHT BY INDEX
IF WA_FLIGHT-CARRID = 'LH'. "CONDITIONAL WHERE EQUAL TO LH
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF.
ENDLOOP.
CHECK 1 = 1.

Tuesday, October 4, 2011

Add Title(heading) to ALV Grid

call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.



*-----------------------------------------------------------*
* 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 = 'EKKO 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.

* Total No. of Records Selected
  describe table it_ekko lines ld_lines.
  ld_linesc = ld_lines.
  concatenate 'Total No. of Records Selected: ' ld_linesc
                    into t_line separated by space.
  wa_header-typ  = 'A'.
  wa_header-info = t_line.
  append wa_header to t_header.
  clear: wa_header, t_line.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
            it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
endform.


http://www.sapdev.co.uk/reporting/alv/alvgrid_rephead.htm