pro sap scripts, smartforms, and data migration978-1-4842-3183-8/1.pdf · pro sap scripts,...

21
Pro SAP Scripts, Smar tforms, and Data Migration ABAP Programming Simplified Sushil Markandeya

Upload: lynhu

Post on 29-Jul-2018

234 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

Pro SAP Scripts, Smar tforms, and Data

MigrationABAP Programming Simplified

Sushil Markandeya

Page 2: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

Pro SAP Scripts, Smartforms, and Data Migration

Sushil Markandeya Saket, New Delhi, India

ISBN-13 (pbk): 978-1-4842-3182-1 ISBN-13 (electronic): 978-1-4842-3183-8https://doi.org/10.1007/978-1-4842-3183-8

Library of Congress Control Number: 2017961575

Copyright © 2017 by Sushil Markandeya

This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.

Cover image by Freepik (www.freepik.com)

Managing Director: Welmoed SpahrEditorial Director: Todd GreenAcquisitions Editor: Nikhil Karkal Development Editor: Matthew MoodieTechnical Reviewer: Srivastava Gauraw Coordinating Editor: Prachi MehtaCopy Editor: Lori Jacobs

Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

For information on translations, please e-mail [email protected], or visit http://www.apress.com/rights-permissions.

Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.

Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-3182-1. For more detailed information, please visit http://www.apress.com/source-code.

Printed on acid-free paper

Page 3: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

To those of my trainees who persuaded me that my classroom training material can be transformed into books.

Page 4: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

v

Contents

About the Author ���������������������������������������������������������������������������������������������������xvii

About the Technical Reviewer ��������������������������������������������������������������������������������xix

Acknowledgments ��������������������������������������������������������������������������������������������������xxi

Introduction ����������������������������������������������������������������������������������������������������������xxiii

■Chapter 1: SAP Script–Forms, Styles, and Standard Texts ������������������������������������ 1

SAP Script–A Brief Description of Its Components ����������������������������������������������������������� 2

An Overview of SAP Script Form Elements �������������������������������������������������������������������������������������������� 3

Style Elements and Standard Text ���������������������������������������������������������������������������������������������������������� 6

SAP Script Form and ABAP Print Programs ���������������������������������������������������������������������� 6

Generating Business Documents Using SAP Script—Architecture ���������������������������������� 7

SAP Script Relationship with Client Code ������������������������������������������������������������������������� 8

SAP Script Relationship with Language Key �������������������������������������������������������������������� 9

Navigation and Transaction Codes ����������������������������������������������������������������������������������� 9

Transaction Code SE74—Format Conversion ��������������������������������������������������������������������������������������� 11

Transaction Code SE75–SAP script Settings ���������������������������������������������������������������������������������������� 11

Fonts in SAP Script Environment ������������������������������������������������������������������������������������ 12

Font Families ���������������������������������������������������������������������������������������������������������������������������������������� 12

Proportionate and Non-proportionate Fonts ����������������������������������������������������������������������������������������� 13

System Fonts ���������������������������������������������������������������������������������������������������������������������������������������� 14

Printer Fonts, System Bar Codes, and Printer Bar Codes ��������������������������������������������������������������������� 15

True Type Font Installation �������������������������������������������������������������������������������������������������������������������� 15

A Note on Naming Convention of Objects in the Book ��������������������������������������������������� 21

Page 5: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

vi

Form Graphics–Import Graphics ������������������������������������������������������������������������������������ 22

Forms: Searching and Classification ������������������������������������������������������������������������������ 25

Dimensions in SAP Script Environment �������������������������������������������������������������������������� 28

A Detail on SAP Script Form Elements–A Tour of the Form MEDRUCK �������������������������� 28

Form Element—Header ������������������������������������������������������������������������������������������������������������������������ 30

Form Element—Page Formats ������������������������������������������������������������������������������������������������������������� 32

Form Elements–Windows and Page Windows�������������������������������������������������������������������������������������� 35

Form Elements–Windows and Page Windows: Tour of Form MEDRUCK Continued ����������������������������� 40

Form Element–Paragraph Formats ������������������������������������������������������������������������������������������������������ 43

Form Element–Character Formats ������������������������������������������������������������������������������������������������������� 46

Form Element—Text Elements ������������������������������������������������������������������������������������������������������������� 48

Demonstration I �������������������������������������������������������������������������������������������������������������� 52

Form Header ����������������������������������������������������������������������������������������������������������������������������������������� 53

Page Format ����������������������������������������������������������������������������������������������������������������������������������������� 53

Specifications of the Text in the Variable Window �������������������������������������������������������������������������������� 54

Paragraph Formats ������������������������������������������������������������������������������������������������������������������������������� 55

Complete Mandatory Entries in the Form Header �������������������������������������������������������������������������������� 56

Windows and page windows ���������������������������������������������������������������������������������������������������������������� 56

Character Formats �������������������������������������������������������������������������������������������������������������������������������� 61

Text in Text Element ������������������������������������������������������������������������������������������������������������������������������ 62

Test or Print Preview Form ������������������������������������������������������������������������������������������������������������������� 64

Recapitulation ��������������������������������������������������������������������������������������������������������������������������������������� 65

Demonstration II ������������������������������������������������������������������������������������������������������������� 66

Create Style YCH01_01 ������������������������������������������������������������������������������������������������������������������������� 66

Create Standard Text YCH01_01_SEL_TABLES ������������������������������������������������������������������������������������� 68

Create Form YCH01_02_SEC_FRM, Page Format FIRST, Graphic Window LOGO, etc� �������������������������� 71

Create a Variable Window VARIABLE, Page Window and Include Standard Text ����������������������������������� 71

Test Print Form YCH01_02_SEC_FRM �������������������������������������������������������������������������������������������������� 73

Recapitulation ��������������������������������������������������������������������������������������������������������������������������������������� 74

Page 6: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

vii

Demonstration III ������������������������������������������������������������������������������������������������������������ 74

Create Form YCH01_03_MLIST1, Page Format FIRST, etc� ������������������������������������������������������������������� 78

Create Variable Window, Its Corresponding Page Window, Create Text Element, etc� �������������������������� 78

Create Page Window for the Main Window, Create Text Element, etc� �������������������������������������������������� 79

Create an ABAP Program YCH01_01_MLIST_ONE_MWINDOW (Print Program), etc� ���������������������������� 80

Test form YCH01_03_MLIST1, Execute Program YCH01_01_MLIST_ONE_MWINDOW ������������������������� 82

Recapitulation ��������������������������������������������������������������������������������������������������������������������������������������� 83

Form Check Text ������������������������������������������������������������������������������������������������������������� 83

Demonstration IV ������������������������������������������������������������������������������������������������������������ 86

Create Form YCH01_04_MLIST2 ���������������������������������������������������������������������������������������������������������� 87

Create and Test ABAP Program YCH01_02_MLIST_TWO_MWINDOWS (Print Program) ����������������������� 90

Test Form YCH01_04_MLIST2, Execute Program YCH01_02_MLIST_TWO_MWINDOWS ��������������������� 91

Recapitulation ��������������������������������������������������������������������������������������������������������������������������������������� 91

Conclusion ���������������������������������������������������������������������������������������������������������������������� 91

■Chapter 2: SAP Script–Hands-on Exercises ��������������������������������������������������������� 93

Hands-on Exercise I–Output Vendors’ Address Labels of a Specific Company Code������������������������������������������������������������������������������������������� 93

Output Specification and Layout ����������������������������������������������������������������������������������������������������������� 94

Output Considerations �������������������������������������������������������������������������������������������������������������������������� 95

Inputs ���������������������������������������������������������������������������������������������������������������������������������������������������� 96

Text element contents in the main window ������������������������������������������������������������������������������������������ 97

Source program ������������������������������������������������������������������������������������������������������������������������������������ 98

Creation of Form YCH02_01_ADR_STK and Print Program YCH02_01_PPRG_YCH02_01_ADR_STK �������������������������������������������������������������������������������������������� 100

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 100

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 101

Hands-on Exercise II—Output Custom Purchase Order ����������������������������������������������� 102

Hands-on Exercise–Scope and Limits ������������������������������������������������������������������������������������������������ 102

Output and Layout Specification ��������������������������������������������������������������������������������������������������������� 102

Output Considerations ������������������������������������������������������������������������������������������������������������������������ 106

Page 7: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

viii

Data Inputs and Data Input Considerations ���������������������������������������������������������������������������������������� 108

Creation of SAP Script Form, Print Program, and Related Workbench Objects ���������������������������������� 110

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 124

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 128

Hands-on Exercise III—Output Custom Purchase Order—Use Control Command PERFORM ���������������������������������������������������������������������������������������������������� 129

Output, Layout Specification, and Output Considerations ������������������������������������������������������������������ 129

Creation of SAP Script Form, Print Program, and Related Workbench Objects ���������������������������������� 131

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 138

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 140

Hands-on Exercise: IV–Copy, Modify, and Customize SAP Delivered Form MEDRUCK ������������������������������������������������������������������������������������������������������������ 140

Output Specifications ������������������������������������������������������������������������������������������������������������������������� 140

Copy Form MEDRUCK to Y Namespace����������������������������������������������������������������������������������������������� 140

Modifications to the Copied Form YCH02_04_MEDRUCK ������������������������������������������������������������������� 142

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 153

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 160

Form YCH02_04_MEDRUCK vis-à-vis Form YCH02_03_PORDER2 ����������������������������������������������������� 160

Hands-on Exercise V—Output Customer-wise Sales Summary of a Company Code—Use SAP Script Form ������������������������������������������������������������������������ 161

Output Specification and Layout ��������������������������������������������������������������������������������������������������������� 161

Data Inputs ����������������������������������������������������������������������������������������������������������������������������������������� 162

SAP Script Form YCH02_05_SALESSUM �������������������������������������������������������������������������������������������� 163

Print Program YCH02_05_PPRG_YCH02_05_SALESUM for SAP Script Form YCH02_05_SALESUM ������������������������������������������������������������������������������������������������������������������������� 165

Check and Activate Form �������������������������������������������������������������������������������������������������������������������� 167

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 167

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 168

Classifying Forms ��������������������������������������������������������������������������������������������������������� 169

SAP Script Form Documentation ���������������������������������������������������������������������������������� 175

SAP Script Tidbits ��������������������������������������������������������������������������������������������������������� 176

Conclusion �������������������������������������������������������������������������������������������������������������������� 177

Page 8: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

ix

■Chapter 3: Smartforms—Forms, Styles, and Text Modules ������������������������������� 179

SAP script and Smartforms—Similarities and Differences ������������������������������������������ 179

Extra Features and Facilities in Smartforms over SAP Script �������������������������������������� 180

SAP Script Objects Available in Smartforms Environment ������������������������������������������� 181

Smartforms Form Elements and Smartforms Form Environment �������������������������������� 181

Application Toolbar ����������������������������������������������������������������������������������������������������������������������������� 182

Menu Bar and Menu Options �������������������������������������������������������������������������������������������������������������� 183

Node: Global Settings ������������������������������������������������������������������������������������������������������������������������� 184

Node: Pages and Windows ����������������������������������������������������������������������������������������������������������������� 189

Recapitulation—Node: Pages and Windows �������������������������������������������������������������������������������������� 213

Smartforms Form Environment—Settings and Field List������������������������������������������������������������������� 214

Smartforms Form and ABAP Driver Program ��������������������������������������������������������������� 215

Generating Business Documents Using Smartforms—Architecture ���������������������������� 215

Demonstration I ������������������������������������������������������������������������������������������������������������ 217

Recapitulation of Specifications of Text in Secondary Window ���������������������������������������������������������� 217

Create Style ���������������������������������������������������������������������������������������������������������������������������������������� 218

Create Form—Form Attributes and Page Format ������������������������������������������������������������������������������� 222

Create Form—Graphic and Secondary Window ��������������������������������������������������������������������������������� 223

Create Form—Text ����������������������������������������������������������������������������������������������������������������������������� 226

Test or Print Preview Form ����������������������������������������������������������������������������������������������������������������� 231

Recapitulation ������������������������������������������������������������������������������������������������������������������������������������� 232

Demonstration II ����������������������������������������������������������������������������������������������������������� 233

Create Text Module YCH03_01_SEL_TABLES ������������������������������������������������������������������������������������� 233

Create Form YCH03_02_SEC_FRM—Page Format FIRST and Graphic Window LOGO ����������������������� 234

Create Form—Create a Secondary Window VARIABLE and Include Text Module ������������������������������� 235

Test Print Form YCH03_02_SEC_FRM ������������������������������������������������������������������������������������������������ 237

Recapitulation ������������������������������������������������������������������������������������������������������������������������������������� 238

Demonstration III ���������������������������������������������������������������������������������������������������������� 238

Create Style YCH03_02 ����������������������������������������������������������������������������������������������������������������������� 241

Create Form YCH03_03_MLIST1, Page Format FIRST, etc� ����������������������������������������������������������������� 241

Page 9: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

x

Create Secondary Window, Create Text, etc� ��������������������������������������������������������������������������������������� 243

Adjust Dimensions of Main Window, Create Text in Main Window, etc� ���������������������������������������������� 245

Create an ABAP Program YCH03_01_MLIST1 (Driver Program), etc� �������������������������������������������������� 246

Test Form YCH03_03_MLIST1, Execute Program YCH03_01_MLIST1 ������������������������������������������������ 247

Recapitulation ������������������������������������������������������������������������������������������������������������������������������������� 248

Demonstration IV ���������������������������������������������������������������������������������������������������������� 248

Create ABAP Dictionary Structure YCH03_2REC_MAKT_STRU ����������������������������������������������������������� 251

Create Form YCH03_04_MLIST2 �������������������������������������������������������������������������������������������������������� 251

Create and Test ABAP Program YCH03_02_MLIST2 (Driver Program) ������������������������������������������������ 254

Test Form YCH03_04_MLIST2, Execute Program YCH03_02_MLIST2 ������������������������������������������������ 257

Recapitulation ������������������������������������������������������������������������������������������������������������������������������������� 258

Conclusion �������������������������������������������������������������������������������������������������������������������� 258

■Chapter 4: Smartforms–Hands-on Exercises ����������������������������������������������������� 259

Hands-on Exercise I—Output Vendors’ Address Labels of a Specific Company Code����������������������������������������������������������������������������������������� 259

Output Specification and Layout ��������������������������������������������������������������������������������������������������������� 260

Output Considerations ������������������������������������������������������������������������������������������������������������������������ 260

Inputs ������������������������������������������������������������������������������������������������������������������������������������������������� 263

Creation of Style YCH04_01, Form YCH04_01_ADR_STK and Driver Program YCH04_01_DPRG_YCH04_01_ADR_STK �������������������������������������������������������������������������������������������� 264

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 272

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 273

Hands-on exercise II—Output Purchase Orders Using Custom Form �������������������������� 274

Hands-on Exercise—Scope and Limits ���������������������������������������������������������������������������������������������� 274

Output and Layout Specification �������������������������������������������������������������������������������������������������������� 275

Output Considerations ������������������������������������������������������������������������������������������������������������������������ 277

Data Inputs and Data Input Considerations ���������������������������������������������������������������������������������������� 278

Creation of Smartforms Form, Driver Program, and Related Workbench Objects ������������������������������ 281

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 307

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 311

Page 10: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xi

Hands-on Exercise III–Copy, Modify, and Customize SAP Delivered Form /SMB40/MMPO_A, etc� ���������������������������������������������������������������������������������������� 311

A Note on the SAP Delivered Smartforms Form /SMB40/MMPO_A ���������������������������������������������������� 312

Stage I: Enable Purchase Order Output with Smartforms Form YSM_SMB40_MMPO_A, ��������������������������������������������������������������������������������������������������������������������� 312

Stage II: Enable Purchase Order Output with a Modified and Customized Copy of Smartforms Form /SMB40/MMPO_A �������������������������������������������������������������������������������������������������� 321

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 327

Smartforms System Fields: SFSY-PAGE and SFSY-FORMPAGES ������������������������������������������������������� 327

Three Page Formats and Runtime Assignment of Page Format with Command Node ���������������������� 328

Forms: /BPR3PF/MMPO_L, /BPR3PF/MMPO_A, and Driver Program /BPR3PF/FM06P ����������������������� 329

Hands-on Exercise: IV–Generate Material Bar Code Labels ����������������������������������������� 329

Output Specification, Major Tasks, etc� ����������������������������������������������������������������������������������������������� 330

Creation of Custom Bar Code YCH_04BC, Assignment to a Print Device �������������������������������������������� 330

Creation of Style YCH04_04 ���������������������������������������������������������������������������������������������������������������� 335

Creation of Form YCH04_04_MATERIAL_BCODES ������������������������������������������������������������������������������ 335

Creation of Driver Program YCH04_04_DPRG_YCH04_04_MBCODES ������������������������������������������������ 341

Execution of Driver Program—Output ������������������������������������������������������������������������������������������������ 342

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 344

Hands-on Exercise V—Output Customer-wise Sales Summary of a Company code—Use Smartforms Form ��������������������������������������������������������������������� 344

Output Specification and Layout ��������������������������������������������������������������������������������������������������������� 345

Data Inputs ����������������������������������������������������������������������������������������������������������������������������������������� 345

Create ABAP Dictionary Structure YCH04_SALES_SUMM_STRU �������������������������������������������������������� 346

Create Smartforms Style YCH04_05 and Form YCH04_05_SALESSUM ��������������������������������������������� 346

Driver Program YCH04_05_DPRG_YCH04_05_SALESUM for Smartforms Form YCH04_05_SALESUM ������������������������������������������������������������������������������������������������������������������������ 351

Output ������������������������������������������������������������������������������������������������������������������������������������������������� 353

Hands-on Exercise Recapitulation ������������������������������������������������������������������������������������������������������ 354

Page 11: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xii

Smartforms Tidbits ������������������������������������������������������������������������������������������������������ 355

Smartforms Opening Screen Menu Options ��������������������������������������������������������������������������������������� 355

Final Window �������������������������������������������������������������������������������������������������������������������������������������� 356

Copy Window �������������������������������������������������������������������������������������������������������������������������������������� 357

Conclusion �������������������������������������������������������������������������������������������������������������������� 357

■ Chapter 5: Migration Using Batch Input Session and Call Transaction Methods ���������������������������������������������������������������������������������� 359

Data Migration–Issues and Considerations ������������������������������������������������������������������ 360

Data Migration–A Brief on Tools and Facilities Available���������������������������������������������� 361

Recording a Transaction, BDCDATA Table, and the Include Program BDCRECX1 ���������� 362

Recording a Transaction, BDCDATA Table ������������������������������������������������������������������������������������������� 363

Include Program BDCRECX1 ��������������������������������������������������������������������������������������������������������������� 368

Determine Program Name, Screen Numbers, Screen Field Names ����������������������������� 371

Hands-on Exercise I: Migrate Vendor Data Using Batch Input Method ����������������������������������������������� 373

Specification and Scope ��������������������������������������������������������������������������������������������������������������������� 373

Data Flow When Running Program Using Batch Input Method ����������������������������������������������������������� 376

Task List ���������������������������������������������������������������������������������������������������������������������������������������������� 378

Perform Recording of Vendor Creation Using Transaction Code XK01 and Save It ����������������������������� 378

Generate an ABAP Program from Saved Recording ���������������������������������������������������������������������������� 385

Perform Modifications to a Copy of the Generated Program �������������������������������������������������������������� 388

Run the Program with the Batch Input Option (Default) for Creation of a Batch Input Session ���������� 395

Run the Batch Input Session in Foreground with Transaction Code SM35 ����������������������������������������� 400

Check and Verify Migration of Vendor Data—Transaction Code XK02 or XK03, etc� �������������������������� 405

Prepare Text Files; Run Program with the Batch Input Option to Create a Session; Run Session in Background and Verify Migration of Data ������������������������������������������������������������������ 405

Issue of Number of Rows Greater Than Visible Number of Rows in Table Control Area ��������������������� 409

Recapitulation—Hands-on Exercise I: Migrate Vendor Data Using Batch Input Method �������������������� 412

Hands-on Exercise II: Migrate Vendor Data Using Call Transaction Method ����������������� 414

Extra Features in the Program ������������������������������������������������������������������������������������������������������������ 414

Migrate Data of Text Files on Application Server Using Call Transaction Method ������������������������������� 415

Page 12: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xiii

Migrate Data of Text Files on Application Server Using Call Transaction Method, Create Log File on Application Server ������������������������������������������������������������������������������������������������� 426

Recapitulation—Hands-on Exercise II: Migrate Vendor Data Using Call Transaction Method ������������ 435

Batch Input vis-à-vis Call Transaction Methods ����������������������������������������������������������� 436

Conclusion �������������������������������������������������������������������������������������������������������������������� 437

■ Chapter 6: Data Migration Using Legacy System Migration Workbench LSMW–I �������������������������������������������������������������������������� 441

LSMW—Project Structure and an Overview of the Opening Screen ���������������������������� 442

Project Structure �������������������������������������������������������������������������������������������������������������������������������� 443

LSMW Opening Screen Overview—Some Application Toolbar Buttons and Menu Options ��������������� 444

A Brief on the LSMW Hands-on Exercises �������������������������������������������������������������������� 446

Hands-on Exercise I—Migration of Vendor Data Using Standard Batch/Direct Input Method ���������������������������������������������������������������������������������������������������������������� 446

Specification and Scope ��������������������������������������������������������������������������������������������������������������������� 447

Create Project, Subproject, and Object ����������������������������������������������������������������������������������������������� 448

Process Step 1—Maintain Object Attributes �������������������������������������������������������������������������������������� 451

Process Step 2—Maintain Source Structures ������������������������������������������������������������������������������������ 453

Process Step 3—Maintain Source Fields ������������������������������������������������������������������������������������������� 455

Process Step 4—Maintain Structure Relations ���������������������������������������������������������������������������������� 457

Process Step 5—Maintain Field Mapping and Conversion Rules ������������������������������������������������������ 458

Process Step 6—Maintain Fixed Values, Translations, and User-Defined Routines �������������������������� 463

Process Step 5—Revisited ����������������������������������������������������������������������������������������������������������������� 465

Process Step 7—Specify Files ���������������������������������������������������������������������������������������������������������� 467

Process Step 8—Assign Files ����������������������������������������������������������������������������������������������������������� 469

Data Creation on Presentation Server, Copy to Application Server ���������������������������������������������������� 470

Process Step 9—Read Data �������������������������������������������������������������������������������������������������������������� 472

Process Step 10–Display Read Data ������������������������������������������������������������������������������������������������� 473

Process Step 11–Convert Data ���������������������������������������������������������������������������������������������������������� 475

Process Step 12–Display Converted Data ����������������������������������������������������������������������������������������� 477

Process Step 13–Create Batch Input Session ����������������������������������������������������������������������������������� 478

Page 13: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xiv

Process Step 14—Run Batch Input Session ������������������������������������������������������������������������������������� 479

Vendor Data Creation—Cross-Verification ���������������������������������������������������������������������������������������� 481

Hands-on Exercise I—Recapitulation ������������������������������������������������������������������������������������������������ 482

Hands-on Exercise II—Migration of Vendor Data Using Batch Input Recording Method �������������������������������������������������������������������������������������������������������� 483

Create Object YCH06_RC and Recording YCH06_XK01 of Transaction Code XK01 ���������������������������� 483

Process Step 1—Maintain Object Attributes �������������������������������������������������������������������������������������� 489

Process Step 2—Maintain Source Structures ������������������������������������������������������������������������������������ 490

Process Step 3—Maintain Source Fields ������������������������������������������������������������������������������������������� 491

Process Step 4—Maintain Structure Relations ���������������������������������������������������������������������������������� 492

Process Step 5—Maintain Field Mapping and Conversion Rules ������������������������������������������������������ 493

Process Step 6—Maintain Fixed Values, Translations, and User-Defined Routines �������������������������� 496

Process Step 5—Revisited ����������������������������������������������������������������������������������������������������������������� 498

Process Step 7—Specify Files ���������������������������������������������������������������������������������������������������������� 499

Process Step 8—Assign Files ����������������������������������������������������������������������������������������������������������� 499

Data Creation on Presentation Server, Copy to Application Server ���������������������������������������������������� 500

Process Step 9—Read Data �������������������������������������������������������������������������������������������������������������� 501

Process Step 11—Convert Data �������������������������������������������������������������������������������������������������������� 501

Process Step 13—Create Batch Input Session ��������������������������������������������������������������������������������� 502

Process Step 14—Run Batch Input Session ������������������������������������������������������������������������������������� 503

Vendor Data Creation—Cross-Verification ���������������������������������������������������������������������������������������� 504

Hands-on Exercise II Recapitulation �������������������������������������������������������������������������������������������������� 506

Process Steps Screen—Menu Options ��������������������������������������������������������������������������������������������� 507

Project, Project Components Export and Import �������������������������������������������������������������������������������� 510

Conclusion �������������������������������������������������������������������������������������������������������������������� 516

■ Chapter 7: Data Migration Using Legacy System Migration Workbench LSMW–II ������������������������������������������������������������������������������������������ 517

Hands-on Exercises in This Chapter—Issues and Considerations ������������������������������� 517

Purchase Order Database Tables ���������������������������������������������������������������������������������� 518

Database Table EKKO �������������������������������������������������������������������������������������������������������������������������� 519

Database Table EKPO �������������������������������������������������������������������������������������������������������������������������� 519

Page 14: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xv

Database Table EKET �������������������������������������������������������������������������������������������������������������������������� 520

Database Tables of Purchasing Documents–ER Diagram and Data Storage �������������������������������������� 521

A Brief on IDocs ������������������������������������������������������������������������������������������������������������ 523

IDoc–A Data Container ������������������������������������������������������������������������������������������������������������������������ 523

IDoc–Deployment Scenarios ��������������������������������������������������������������������������������������������������������������� 524

IDocs–Storage in Database Tables ����������������������������������������������������������������������������������������������������� 524

IDocs–Outbound and Inbound Processing ������������������������������������������������������������������������������������������ 524

IDocs–ALE Technology, SAP Ready-to-Use IDocs ������������������������������������������������������������������������������� 526

IDoc Components–A Look at the IDoc Type PORDCR05 ���������������������������������������������������������������������� 526

Hands-on Exercise III–Migration of Purchase Order Data Using IDoc ������������������������� 534

Specification and Scope ��������������������������������������������������������������������������������������������������������������������� 534

Perform IDoc Inbound Settings ����������������������������������������������������������������������������������������������������������� 537

Create Subproject YCH07_PO ������������������������������������������������������������������������������������������������������������� 543

Create Object YCH07_IDOC ����������������������������������������������������������������������������������������������������������������� 544

Process Step 1–Maintain Object Attributes ���������������������������������������������������������������������������������������� 545

Process Step 2–Maintain Source Structures �������������������������������������������������������������������������������������� 546

Process Step 3–Maintain Source Fields ��������������������������������������������������������������������������������������������� 547

Process Step 4–Maintain Structure Relations ������������������������������������������������������������������������������������ 547

Process Step 5–Maintain Field Mapping and Conversion Rules��������������������������������������������������������� 548

Process Step 7–Specify Files ������������������������������������������������������������������������������������������������������������ 550

Process Step 8–Assign Files ������������������������������������������������������������������������������������������������������������� 551

Data Creation on Presentation Server ����������������������������������������������������������������������������������������������� 551

Process Step 9–Read Data ���������������������������������������������������������������������������������������������������������������� 552

Process Step 10—Display Read Data ����������������������������������������������������������������������������������������������� 553

Process Step 11—Convert Data �������������������������������������������������������������������������������������������������������� 553

Process Step 12—Display Converted Data ��������������������������������������������������������������������������������������� 554

Process Step 13—Start IDoc Generation ������������������������������������������������������������������������������������������ 555

Process Step 14—Start IDoc Processing ������������������������������������������������������������������������������������������ 555

Process Step 15—Create IDoc Overview ������������������������������������������������������������������������������������������� 559

Process Step 16—Start IDoc Follow-Up ��������������������������������������������������������������������������������������������� 559

Purchase Orders Created—Cross-Verification with Input Data ��������������������������������������������������������� 560

Hands-on Exercise III—Recapitulation ���������������������������������������������������������������������������������������������� 566

Page 15: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ Contents

xvi

Hands-on Exercise IV—Migration of Purchase Order Data Using Business Object Method ������������������������������������������������������������������������������������������������������������� 567

Deficiencies of Hands-on Exercise III—Rectification ������������������������������������������������������������������������� 567

Specification and Scope ��������������������������������������������������������������������������������������������������������������������� 567

Create Object YCH07_BAPI ����������������������������������������������������������������������������������������������������������������� 569

Process Step 1—Maintain Object Attributes �������������������������������������������������������������������������������������� 570

Process Step 2—Maintain Source Structures ������������������������������������������������������������������������������������ 572

Process Step 3—Maintain Source Fields ������������������������������������������������������������������������������������������� 572

Process Step 4—Maintain Structure Relations ���������������������������������������������������������������������������������� 573

Process Step 5—Maintain Field Mapping and Conversion Rules ������������������������������������������������������ 574

Process Step 7—Specify Files ���������������������������������������������������������������������������������������������������������� 576

Process Step 8—Assign Files ����������������������������������������������������������������������������������������������������������� 577

Data Creation on Presentation Server ����������������������������������������������������������������������������������������������� 578

Process Step 9—Read Data �������������������������������������������������������������������������������������������������������������� 579

Process Step 10—Display Read Data ����������������������������������������������������������������������������������������������� 579

Process Step 11—Convert Data �������������������������������������������������������������������������������������������������������� 580

Process Step 12—Display Converted Data ��������������������������������������������������������������������������������������� 581

Process Step 13—Start IDoc Generation ������������������������������������������������������������������������������������������ 581

Process Step 14—Start IDoc Processing ������������������������������������������������������������������������������������������ 582

Process Step 15—Create IDoc Overview ������������������������������������������������������������������������������������������� 584

Process Step 16—Start IDoc Follow-Up ��������������������������������������������������������������������������������������������� 584

Purchase Orders Created—Cross-Verification with Input Data ��������������������������������������������������������� 585

Hands-on Exercise IV—Recapitulation ���������������������������������������������������������������������������������������������� 589

Project Components Export ����������������������������������������������������������������������������������������� 590

Conclusion ������������������������������������������������������������������������������������������������������������������� 592

Index ��������������������������������������������������������������������������������������������������������������������� 593

Page 16: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

xvii

About the Author

Sushil Markandeya is a B.E. from Osmania University (1973) and M.E. (Electrical Engineering) from B.I.T.S.—Pilani. (1975) In 1977, he shifted to Information Technology. He has always been involved in creating business application software on various platforms.

Since July 2006, he has been doing corporate training in SAP ABAP for people just out of college. Some of the major Indian corporate clients he has trained for are Accenture, Wipro group Sony India, Mphasis (part of H.P), ITC Info tech., Hyundai Motor, Godrej Info tech., CGI, Orient Cements, and Sopra India.

He, along with Kaushik Roy, authored the book: SAP ABAP—Hands-On Test Projects with Business Scenarios (Apress, 2014).

Presently, he is located in Delhi, India.

Page 17: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

xix

About the Technical Reviewer

Srivastava Gauraw is a SAP Technofunctional Consultant. He holds several certificates in SAP. He has been working as an independent consultant providing his services in development, training, and documentation, and troubeshooting queries during SAP implementation. He has expertise in ABAP, HANA, Workflow, and other technical and functional aspects of SAP.

Page 18: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

xxi

Acknowledgments

The manuscript submitted by the author to the publisher goes through a series of processes, mostly of an editorial nature, to produce the book. My acknowledgements to the following editorial and allied personnel of Apress (in chronological order of my first interaction with them)

Mr. Nikhil Karkal Acquisitions EditorMr. Celestin Suresh John Senior EditorMs. Prachi Mehta Coordinating EditorMr. Matthew Moodie Lead Development Editor

Acknowledgements to the personnel of Springer and Apress who worked behind the scenes to produce this book.

Acknowledgements to the technical reviewer Mr. Srivastava Gauraw.

Page 19: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

xxiii

Introduction

The present book Pro SAP Scripts, Smartforms, and Data Migration, is a sequel to our earlier book SAP ABAP—Hands-On Test Projects with Business Scenarios. It is perceived by enterprises or corporates that an entry-level ABAP consultant must be well grounded in the topics contained in the two books. Personnel trained in classrooms on the topics contained in the two books were included as a shadow resource in the SAP project teams. Subsequently, after three to six months, the shadow resource graduated to a tangible resource in the project teams.

The books come from the training material created for the corporate trainings by the authors. They can now serve as training material for classroom training, individual learning, and reference material for experienced consultants.

Target AudienceThe book is basically addressing people who want to learn SAP Scripts, Smartforms, and Data Migration afresh and people who have been working in these areas for a few years (0-4 years). People with experience in these areas will find this book useful as a reference in the context of doing things.

Target Audience PrerequisitesIdeally, people who want to read this book should have read the book SAP ABAP—Hands-On Test Projects with Business Scenarios and grasped the concepts presented in that book. Alternatively, to be able to comprehend the contents of the present book, the reader should have been exposed to the following areas of ABAP:

• ABAP dictionary—domains, data elements, tables, text tables, structures, database views, search helps, etc.

• ABAP language elements—declarations, arithmetic, string manipulation, conditions, looping, etc.

• Reporting—classical and ALV

• Internal tables—filling, retrieval, initialization, etc.

• Modularization—includes, subroutines, and function modules

• Open SQL

• Selection screens

• Dynpro programming

• ABAP debugger, messages, field symbols, etc.

• Familiarity with the basic functional module database tables of sales and purchase

Page 20: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ IntroduCtIon

xxiv

Though project experience is not essential, the target audience must have worked extensively in the ABAP workbench environment in the areas mentioned previously.

Book’s ApproachThis book’s major thrust is on the “doing” part: to be able to create objects and programs required as per a defined context or scenario.

The book, for most part, uses a scenario-orientated presentation. Concepts and features are communicated through illustrative examples and scenarios. Wherever possible, business scenarios are used to communicate concepts and features.

The book is a completely practical approach, demonstrating and conveying the topics and features through demonstration and hands-on examples.

The demonstration and hands-on exercise objects, including the programs, rely on some of the SAP functional module database tables being populated. This is assured if the reader is logged on to an IDES (Internet demonstration and evaluation system) server or system. An IDES server is now a de facto system for all SAP training-related activities. Specifically, SAP functional module database tables used for demonstration and hands-on exercises in the book are the basic database tables of sales and purchase. Most people with nil or little exposure to business and the commercial world relate to the business areas of sales and purchase.

All the hands-on exercises in the book are performed using SAP sales and purchase functional module database tables.

The author strongly insists that you perform the demonstration and hands-on exercises as you read a chapter and come to the exercises, not defer to performing them after completing a chapter or the book. It should not be just reading but reading and simultaneously performing the demonstration and hands-on exercises.

ResourcesThe book is complemented and supplemented with an E-resource containing various objects including a source program created during the performance of the demonstration and hands-on exercises in the book. We recommend that you read the document A Guide to Use E-resource, located in the folder E_RESOURCE before you commence reading the book.

Most source programs in the E-resource are also listed in the book. Some source programs of E-resource are partially listed in the book and some are not listed in the book. This is indicated in the respective chapters.

In addition to the book and the E-resource, you will use the following additional resources:

• You must have connectivity to the SAP system, specifically, a SAP IDES server. Your log-in user id must be able to create, edit, and delete objects in the ABAP workbench environment. Your log-in user id must be able to access and update data of SAP functional module database tables.

• Apart from book reading, some extra reading is required.

• You will need to read extra theory and description not exposited in the book.

• You need to refer to some detailed information like all formatting options available in the SAP Script environment, a complete list of SAP Script control commands, etc.

Page 21: Pro SAP Scripts, Smartforms, and Data Migration978-1-4842-3183-8/1.pdf · Pro SAP Scripts, Smartforms, and Data Migration ABAP Programming Simplified Sushil Markandeya. Pro SAP Scripts,

■ IntroduCtIon

xxv

The material for most of the above-mentioned readings is available in freely downloadable PDF documents from the following link http://www.easymarketplace.de/online-pdfs.php. You will not violate any copyright law by downloading the documents from this link. These are PDF documents of SAP version 4.6C. Though the documents are older version, they will largely serve your purposes.

Download the following PDF documents from the link http://www.easymarketplace.de/online-pdfs.php. For downloading a specific document, click the link (consolut mirror) against the document title.

• BC Style and Form Maintenance BCSRVSCRFORM.pdf

• SAP Smart Forms (BC-SRV-SCR) BCSRVSCRSF.pdf

• BC Basis Programming Interfaces BCDWBLIB.pdf

(Consider topics of data transfer only)

You will need to refer (not read) to these documents for information during chapter readings. If you do want to read these documents, preferably, do not read them while you are reading a chapter. Read these documents between chapters. At what stage you are to refer to which of these documents is indicated in the book’s chapters.

• After completing a chapter, you can also visit the SAP portal of online documentation. You can look up the chapter’s topic in the online documentation.

Conventions Used in the BookThe following conventions were used in the book:

• All ABAP workbench object names appear in upper case or capitals

• All references to ABAP workbench objects you are expected to be exposed to (as a prerequisite) appear in lower case. For example, program, data element, message class, and so on.

• Generally, terms which are supposedly new to the first-time reader of topics in the book will appear in italics. All components of topics covered will appear in italics. The topic itself will not appear in italics. For example, the topic SAP Script—no italics. SAP Script components: Form, Style—in italics. SAP Script fonts—no italics, because you are expected to know what fonts are.

• All nomenclatures or screen field labels in the running text will appear in italics.

ConclusionA caution on similar sounding terms: function module and functional module. A function module is part of the ABAP modularization feature. A functional module is, loosely, a SAP functional area like sales or purchase.

So on to stimulating reading. Not just readings though, the exercises should be performed simultaneously with the readings.